Skip to content

Commit 20af5b8

Browse files
committed
Add a 'slow' test marker and a command line option '--no-skip-slow':
slow tests will be skipped by default.
1 parent 90b97af commit 20af5b8

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,28 @@
4848
logging.getLogger('suds.client').setLevel(logging.CRITICAL)
4949
logging.getLogger('suds').setLevel(logging.ERROR)
5050

51+
_skip_slow = True
5152
testdir = Path(__file__).resolve().parent
5253
testdatadir = testdir / "data"
5354

55+
def pytest_addoption(parser):
56+
parser.addoption("--no-skip-slow", action="store_true", default=False,
57+
help="do not skip slow tests.")
58+
59+
def pytest_configure(config):
60+
global _skip_slow
61+
_skip_slow = not config.getoption("--no-skip-slow")
62+
config.addinivalue_line("markers", "slow: mark a test as slow, "
63+
"the test will be skipped unless --no-skip-slow "
64+
"is set on the command line")
65+
66+
def pytest_runtest_setup(item):
67+
"""Skip slow tests by default.
68+
"""
69+
marker = item.get_closest_marker("slow")
70+
if marker is not None and _skip_slow:
71+
pytest.skip("skip slow test")
72+
5473
def _skip(reason):
5574
if Version(pytest.__version__) >= '3.3.0':
5675
pytest.skip(reason, allow_module_level=True)

0 commit comments

Comments
 (0)