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

Function get_pytest_path

tools/testsuite/pytest.py:28–52  ·  view source on GitHub ↗

Get the pytest executable path from venv or system.

(ctx: Context, venv_path: str = None)

Source from the content-addressed store, hash-verified

26
27
28def get_pytest_path(ctx: Context, venv_path: str = None) -> pathlib.Path | None:
29 """
30 Get the pytest executable path from venv or system.
31 """
32 if venv_path:
33 pytest_bin = pathlib.Path(venv_path) / "bin" / "pytest"
34 if pytest_bin.exists():
35 return pytest_bin
36 else:
37 ctx.error(f"pytest not found in venv: {pytest_bin}")
38 return None
39
40 # Try to find pytest in PATH
41 pytest_bin_str = shutil.which("pytest")
42 if pytest_bin_str:
43 return pathlib.Path(pytest_bin_str)
44
45 # Try default venv310
46 default_venv = tools.utils.REPO_ROOT / "venv310" / "bin" / "pytest"
47 if default_venv.exists():
48 ctx.info(f"Using pytest from default venv: {default_venv}")
49 return default_venv
50
51 ctx.error("pytest not found. Install pytest or provide --venv path")
52 return None
53
54
55@pytest_cmd.command(

Callers 3

run_pytestFunction · 0.85
last_failedFunction · 0.85
run_patternFunction · 0.85

Calls 3

existsMethod · 0.45
errorMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected