allow flaky to double group

This commit is contained in:
cmcmarrow 2023-06-27 23:12:11 -05:00 committed by Pedro Algarvio
parent ffa67b257c
commit 1f8dc3c510

View file

@ -578,37 +578,37 @@ def pytest_runtest_setup(item):
item._skipped_by_mark = True
pytest.skip(PRE_PYTEST_SKIP_REASON)
test_group_count = sum(
bool(item.get_closest_marker(group))
for group in ("core_test", "slow_test", "flaky_jail")
bool(item.get_closest_marker(group)) for group in ("core_test", "slow_test")
)
if test_group_count > 1:
if item.get_closest_marker("core_test") and item.get_closest_marker("slow_test"):
raise pytest.UsageError(
"Tests can only be in one test group. ('core_test', 'slow_test', 'flaky_jail')"
"Tests can only be in one test group. ('core_test', 'slow_test')"
)
if item.get_closest_marker("core_test"):
if not item.config.getoption("--core-tests"):
raise pytest.skip.Exception(
"Core tests are disabled, pass '--core-tests' to enable them.",
_use_item_location=True,
)
if item.get_closest_marker("slow_test"):
if not item.config.getoption("--slow-tests"):
raise pytest.skip.Exception(
"Slow tests are disabled, pass '--run-slow' to enable them.",
_use_item_location=True,
)
if item.get_closest_marker("flaky_jail"):
if not item.config.getoption("--flaky-jail"):
raise pytest.skip.Exception(
"flaky jail tests are disabled, pass '--flaky-jail' to enable them.",
_use_item_location=True,
)
if test_group_count == 0 and not item.config.getoption("--no-fast-tests"):
raise pytest.skip.Exception(
"Fast tests are disabled, dont pass '--no-fast-tests' to enable them.",
_use_item_location=True,
)
else:
if item.get_closest_marker("core_test"):
if not item.config.getoption("--core-tests"):
raise pytest.skip.Exception(
"Core tests are disabled, pass '--core-tests' to enable them.",
_use_item_location=True,
)
if item.get_closest_marker("slow_test"):
if not item.config.getoption("--slow-tests"):
raise pytest.skip.Exception(
"Slow tests are disabled, pass '--run-slow' to enable them.",
_use_item_location=True,
)
if test_group_count == 0 and not item.config.getoption("--no-fast-tests"):
raise pytest.skip.Exception(
"Fast tests have been disabled by '--no-fast-tests'.",
_use_item_location=True,
)
requires_sshd_server_marker = item.get_closest_marker("requires_sshd_server")
if requires_sshd_server_marker is not None: