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

Function run_pytest

tools/testsuite/pytest.py:70–107  ·  view source on GitHub ↗

Run pytest directly with the specified test path. Examples: * Run a specific test file: tools ts pytest run tests/pytests/unit/test_loader.py * Run a specific test with verbose output: tools ts pytest run tests/pytests/unit/test_loader.py::test_load_modules

(
    ctx: Context,
    test_path: str,
    venv: str = None,
    args: list[str] = None,
)

Source from the content-addressed store, hash-verified

68 },
69)
70def run_pytest(
71 ctx: Context,
72 test_path: str,
73 venv: str = None,
74 args: list[str] = None,
75):
76 """
77 Run pytest directly with the specified test path.
78
79 Examples:
80
81 * Run a specific test file:
82
83 tools ts pytest run tests/pytests/unit/test_loader.py
84
85 * Run a specific test with verbose output:
86
87 tools ts pytest run tests/pytests/unit/test_loader.py::test_load_modules --args -v -x
88
89 * Run using a custom venv:
90
91 tools ts pytest run tests/pytests/unit/test_loader.py --venv ./my_venv
92 """
93 if TYPE_CHECKING:
94 assert test_path is not None
95
96 pytest_bin = get_pytest_path(ctx, venv)
97 if pytest_bin is None:
98 ctx.exit(1)
99
100 # Build pytest command
101 cmd = [str(pytest_bin), test_path]
102 if args:
103 cmd.extend(args)
104
105 ctx.info(f"Running: {' '.join(cmd)}")
106 ret = ctx.run(*cmd, check=False, cwd=tools.utils.REPO_ROOT)
107 ctx.exit(ret.returncode)
108
109
110@pytest_cmd.command(

Callers

nothing calls this directly

Calls 5

get_pytest_pathFunction · 0.85
exitMethod · 0.80
extendMethod · 0.45
infoMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected