Skip to content

Commit 05ef2e6

Browse files
committed
DEP: add pytest-skip-slow as a dependency and remove redundant definitions
1 parent f7e77fe commit 05ef2e6

3 files changed

Lines changed: 4 additions & 44 deletions

File tree

README.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ This is a meta-package that pulls in the dependencies that are used by
1010
`astropy`_ and some `affiliated packages`_ for testing. It can also be used for
1111
testing packages that are not affiliated with the Astropy project.
1212

13-
This package also provides pytest markers for cpu and memory intensive tests
14-
(``pytest.mark.slow`` and ``pytest.mark.hugemem``). Tests marked with those
15-
markers are not run by default, can be run with the other tests with
16-
``--run-slow`` and ``--run-hugemem``, and can be run separately with ``-m slow``
17-
and ``-m hugemem``.
18-
1913
The package also provides the short option ``-R`` for ``--remote-data``.
2014

2115
.. _astropy: https://docs.astropy.org/en/latest/
@@ -39,6 +33,8 @@ The following dependencies are installed by this package:
3933
* `pytest-mock`_, a thin-wrapper around the mock package for easier use
4034
with ``pytest``.
4135
* `pytest-cov`_, a ``pytest`` plugin to measure test coverage.
36+
* `pytest-skip-slow`_, a ``pytest`` plugin to mark tests as slow or memory intensive,
37+
and skip them by default.
4238
* `hypothesis`_, a Python library for property based testing.
4339

4440
.. _pytest: https://doc.pytest.org
@@ -49,6 +45,7 @@ The following dependencies are installed by this package:
4945
.. _pytest-filter-subpackage: https://github.com/astropy/pytest-filter-subpackage
5046
.. _pytest-mock: https://github.com/pytest-dev/pytest-mock
5147
.. _pytest-cov: https://github.com/pytest-dev/pytest-cov
48+
.. _pytest-skip-slow: https://github.com/okken/pytest-skip-slow
5249
.. _hypothesis: https://hypothesis.readthedocs.io
5350

5451
Installation

pytest_astropy/plugin.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,7 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22

3-
# Add a --run-slow and --run-hugemem options to run cpu and memory
4-
# intensive tests
5-
6-
import pytest
7-
8-
93
def pytest_addoption(parser):
10-
parser.addoption(
11-
"--run-slow",
12-
action="store_true",
13-
default=False,
14-
help="run slow tests",
15-
)
16-
parser.addoption(
17-
"--run-hugemem",
18-
action="store_true",
19-
default=False,
20-
help="run memory intensive tests",
21-
)
224
parser.addoption(
235
"-R", nargs="?", const='any', default='none',
246
help="run tests with online data, requires pytest-remotedata",
257
dest="remote_data", choices=['astropy', 'any', 'github', 'none'])
26-
27-
28-
def pytest_configure(config):
29-
config.addinivalue_line("markers", "slow: mark test as slow to run")
30-
config.addinivalue_line("markers",
31-
"hugemem: mark test as using a lot of memory")
32-
33-
34-
def pytest_collection_modifyitems(config, items):
35-
run_slow = config.getoption("--run-slow")
36-
run_hugemem = config.getoption("--run-hugemem")
37-
38-
skip_slow = pytest.mark.skip(reason="need --run-slow option to run")
39-
skip_hugemem = pytest.mark.skip(reason="need --run-hugemem option to run")
40-
41-
for item in items:
42-
if "slow" in item.keywords and not run_slow:
43-
item.add_marker(skip_slow)
44-
if "hugemem" in item.keywords and not run_hugemem:
45-
item.add_marker(skip_hugemem)

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ install_requires =
4141
pytest-filter-subpackage>=0.1.2
4242
pytest-cov>=2.3.1
4343
pytest-mock>=2.0
44+
pytest-skip-slow>=1.1.0
4445
hypothesis>=5.1
4546
# We don't include the following for now since it brings in
4647
# matplotlib as a dependency.

0 commit comments

Comments
 (0)