Skip to content

Commit 6d3d30e

Browse files
committed
Skip slow tests unless --run-slow is specified.
`pytest --run-slow` OR `python3 setup.py test --args=--run-slow`
1 parent 614b717 commit 6d3d30e

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

docs/install.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,15 @@ in order to use `sbpy` in your default Python environment. If you plan to work o
7474
.. code-block:: bash
7575
7676
$ python setup.py develop --user
77+
78+
79+
Running tests
80+
^^^^^^^^^^^^^
81+
82+
To verify your installation is properly working, run `sbpy`'s testing suite:
83+
84+
.. code-block:: bash
85+
86+
$ python3 setpy.py test
87+
88+
Add the `--remote-data` option to include tests that require a network connection, and `-args="--run-slow"` to include any slow tests.

sbpy/activity/gas/tests/test_prodrate_remote.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def data_path(filename):
5959
return os.path.join(data_dir, filename)
6060

6161

62+
@pytest.mark.slow
6263
@remote_data
6364
def test_remote_prodrate_simple_hcn():
6465

@@ -142,6 +143,7 @@ def test_remote_prodrate_simple_ch3oh():
142143
assert np.all(err < 0.35)
143144

144145

146+
@pytest.mark.slow
145147
@remote_data
146148
def test_einstein():
147149

sbpy/conftest.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# by importing them here in conftest.py they are discoverable by py.test
33
# no matter how it is invoked within the source tree.
44

5+
import pytest
56
from astropy.version import version as astropy_version
67

78
if astropy_version < '3.0':
@@ -15,8 +16,8 @@
1516
# variables that are used for configuration.
1617
from astropy.tests.plugins.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
1718

18-
## Uncomment the following line to treat all DeprecationWarnings as
19-
## exceptions
19+
# Uncomment the following line to treat all DeprecationWarnings as
20+
# exceptions
2021
# enable_deprecations_as_exceptions()
2122

2223
# Uncomment and customize the following lines to add/remove entries from
@@ -45,3 +46,26 @@
4546
packagename = os.path.basename(os.path.dirname(__file__))
4647
TESTED_VERSIONS[packagename] = version
4748
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

Comments
 (0)