Skip to content

Commit b0b6121

Browse files
committed
add pytest --skipslow
1 parent 574cf69 commit b0b6121

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

control/tests/conftest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,27 @@ def mplcleanup():
119119
mpl.units.registry.clear()
120120
mpl.units.registry.update(save)
121121
mpl.pyplot.close("all")
122+
123+
124+
#
125+
# Functionality to skip slow tests using --skipslow
126+
#
127+
# See https://docs.pytest.org/en/latest/example/simple.html
128+
# #control-skipping-of-tests-according-to-command-line-option
129+
#
130+
def pytest_addoption(parser):
131+
parser.addoption(
132+
"--skipslow", action="store_true", default=False,
133+
help="skip slow tests")
134+
135+
136+
def pytest_configure(config):
137+
config.addinivalue_line("markers", "slow: mark test as slow to run")
138+
139+
140+
def pytest_collection_modifyitems(config, items):
141+
if config.getoption("--skipslow"):
142+
skip_slow = pytest.mark.skip(reason="skipping slow tests")
143+
for item in items:
144+
if "slow" in item.keywords:
145+
item.add_marker(skip_slow)

0 commit comments

Comments
 (0)