MCPcopy
hub / github.com/saltstack/salt / pytest_runtest_setup

Function pytest_runtest_setup

tests/conftest.py:660–899  ·  view source on GitHub ↗

Fixtures injection based on markers or test skips based on CLI arguments

(item)

Source from the content-addressed store, hash-verified

658# ----- Test Setup -------------------------------------------------------------------------------------------------->
659@pytest.hookimpl(tryfirst=True)
660def pytest_runtest_setup(item):
661 """
662 Fixtures injection based on markers or test skips based on CLI arguments
663 """
664 integration_utils_tests_path = str(TESTS_DIR / "integration" / "utils")
665 if (
666 str(item.fspath).startswith(integration_utils_tests_path)
667 and PRE_PYTEST_SKIP_OR_NOT is True
668 ):
669 item._skipped_by_mark = True
670 pytest.skip(PRE_PYTEST_SKIP_REASON)
671 test_group_count = sum(
672 bool(item.get_closest_marker(group))
673 for group in ("core_test", "slow_test", "flaky_jail")
674 )
675 if item.get_closest_marker("core_test") and item.get_closest_marker("slow_test"):
676 raise pytest.UsageError(
677 "Tests can only be in one test group. ('core_test', 'slow_test')"
678 )
679
680 if item.get_closest_marker("flaky_jail"):
681 if not item.config.getoption("--flaky-jail"):
682 raise pytest.skip.Exception(
683 "flaky jail tests are disabled, pass '--flaky-jail' to enable them.",
684 _use_item_location=True,
685 )
686 else:
687 if item.get_closest_marker("core_test"):
688 if not item.config.getoption("--core-tests"):
689 raise pytest.skip.Exception(
690 "Core tests are disabled, pass '--core-tests' to enable them.",
691 _use_item_location=True,
692 )
693 if item.get_closest_marker("slow_test"):
694 if not item.config.getoption("--slow-tests"):
695 raise pytest.skip.Exception(
696 "Slow tests are disabled, pass '--run-slow' to enable them.",
697 _use_item_location=True,
698 )
699 if test_group_count == 0 and item.config.getoption("--no-fast-tests"):
700 raise pytest.skip.Exception(
701 "Fast tests have been disabled by '--no-fast-tests'.",
702 _use_item_location=True,
703 )
704
705 requires_sshd_server_marker = item.get_closest_marker("requires_sshd_server")
706 if requires_sshd_server_marker is not None:
707 if not item.config.getoption("--ssh-tests"):
708 item._skipped_by_mark = True
709 pytest.skip("SSH tests are disabled, pass '--ssh-tests' to enable them.")
710 item.fixturenames.append("sshd_server")
711 item.fixturenames.append("salt_ssh_roster_file")
712
713 requires_salt_modules_marker = item.get_closest_marker("requires_salt_modules")
714 if requires_salt_modules_marker is not None:
715 required_salt_modules = requires_salt_modules_marker.args
716 if len(required_salt_modules) == 1 and isinstance(
717 required_salt_modules[0], (list, tuple, set)

Callers

nothing calls this directly

Calls 11

generate_entropyMethod · 0.95
_grains_for_markerFunction · 0.85
EntropyGeneratorClass · 0.85
formatMethod · 0.80
setFunction · 0.50
listFunction · 0.50
appendMethod · 0.45
getMethod · 0.45
copyMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected