Skip to content

Commit

Permalink
Add a 'slow' test marker and a command line option '--no-skip-slow':
Browse files Browse the repository at this point in the history
slow tests will be skipped by default.
  • Loading branch information
RKrahl committed Nov 24, 2024
1 parent 90b97af commit 20af5b8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,28 @@
logging.getLogger('suds.client').setLevel(logging.CRITICAL)
logging.getLogger('suds').setLevel(logging.ERROR)

_skip_slow = True
testdir = Path(__file__).resolve().parent
testdatadir = testdir / "data"

def pytest_addoption(parser):
parser.addoption("--no-skip-slow", action="store_true", default=False,
help="do not skip slow tests.")

def pytest_configure(config):
global _skip_slow
_skip_slow = not config.getoption("--no-skip-slow")
config.addinivalue_line("markers", "slow: mark a test as slow, "
"the test will be skipped unless --no-skip-slow "
"is set on the command line")

def pytest_runtest_setup(item):
"""Skip slow tests by default.
"""
marker = item.get_closest_marker("slow")
if marker is not None and _skip_slow:
pytest.skip("skip slow test")

def _skip(reason):
if Version(pytest.__version__) >= '3.3.0':
pytest.skip(reason, allow_module_level=True)
Expand Down

0 comments on commit 20af5b8

Please sign in to comment.