|
2 | 2 | # by importing them here in conftest.py they are discoverable by py.test |
3 | 3 | # no matter how it is invoked within the source tree. |
4 | 4 |
|
| 5 | +import pytest |
5 | 6 | from astropy.version import version as astropy_version |
6 | 7 |
|
7 | 8 | if astropy_version < '3.0': |
|
15 | 16 | # variables that are used for configuration. |
16 | 17 | from astropy.tests.plugins.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS |
17 | 18 |
|
18 | | -## Uncomment the following line to treat all DeprecationWarnings as |
19 | | -## exceptions |
| 19 | +# Uncomment the following line to treat all DeprecationWarnings as |
| 20 | +# exceptions |
20 | 21 | # enable_deprecations_as_exceptions() |
21 | 22 |
|
22 | 23 | # Uncomment and customize the following lines to add/remove entries from |
|
45 | 46 | packagename = os.path.basename(os.path.dirname(__file__)) |
46 | 47 | TESTED_VERSIONS[packagename] = version |
47 | 48 | TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version |
| 49 | + |
| 50 | + |
| 51 | +# Add option to control run/skip of slow test (pytest.mark.slow) |
| 52 | + |
| 53 | + |
| 54 | +def pytest_addoption(parser): |
| 55 | + parser.addoption( |
| 56 | + "--run-slow", action="store_true", default=False, help="run slow tests" |
| 57 | + ) |
| 58 | + |
| 59 | + |
| 60 | +def pytest_configure(config): |
| 61 | + config.addinivalue_line("markers", "slow: mark test as slow to run") |
| 62 | + |
| 63 | + |
| 64 | +def pytest_collection_modifyitems(config, items): |
| 65 | + if config.getoption("--run-slow"): |
| 66 | + # --run-slow given in cli: do not skip slow tests |
| 67 | + return |
| 68 | + skip_slow = pytest.mark.skip(reason="need --run-slow option to run") |
| 69 | + for item in items: |
| 70 | + if "slow" in item.keywords: |
| 71 | + item.add_marker(skip_slow) |
0 commit comments