Skip to content

Commit 9570493

Browse files
Yaol2yao
authored andcommitted
Mark slow test to skip in default pytest
1 parent cd6add3 commit 9570493

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

tests/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@
3434

3535
def pytest_addoption(parser):
3636
parser.addoption("--boto-model-file", action="store", default=None)
37+
parser.addoption("--runslow", action="store_true", default=False, help="run slow tests")
38+
39+
40+
def pytest_configure(config):
41+
config.addinivalue_line("markers", "slow: mark test as slow to run")
42+
43+
44+
def pytest_collection_modifyitems(config, items):
45+
if config.getoption("--runslow"):
46+
# --runslow given in cli: do not skip slow tests
47+
return
48+
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
49+
for item in items:
50+
if "slow" in item.keywords:
51+
item.add_marker(skip_slow)
3752

3853

3954
@pytest.fixture(scope="session")

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ passenv =
4949
# {posargs} can be passed in by additional arguments specified when invoking tox.
5050
# Can be used to specify which tests to run, e.g.: tox -- -s
5151
commands =
52-
coverage run --source smexperiments -m pytest {posargs} -m "not slow"
52+
coverage run --source smexperiments -m pytest {posargs}
5353
{env:IGNORE_COVERAGE:} coverage report --fail-under=95
5454
extras = test
5555
deps =
@@ -95,7 +95,7 @@ passenv =
9595
# {posargs} can be passed in by additional arguments specified when invoking tox.
9696
# Can be used to specify which tests to run, e.g.: tox -- -s
9797
commands =
98-
pytest {posargs} --verbose -m "slow" --capture=no
98+
pytest {posargs} --verbose --runslow --capture=no
9999
extras = test
100100
deps =
101101
boto3 >= 1.10.32

0 commit comments

Comments
 (0)