34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from trusted_evidence_providers import _run, _tests_env
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_tests_env_forwards_app_and_repo_root_on_path():
|
|
"""The tests provider must run the real suite under the documented
|
|
PYTHONPATH so subprocess-spawning tests (e.g. job-safety process-crash
|
|
recovery) can import runtime modules from active-runtime/app."""
|
|
env = _tests_env(REPO_ROOT)
|
|
parts = env["PYTHONPATH"].split(os.pathsep)
|
|
assert str(REPO_ROOT) in parts
|
|
assert str(REPO_ROOT / "active-runtime" / "app") in parts
|
|
|
|
|
|
def test_run_extra_env_reaches_pytest_child_process():
|
|
"""_run must forward an extra environment (PYTHONPATH) into the child so a
|
|
subprocess spawned by a test inherits the repo runtime path, not just the
|
|
in-process sys.path that conftest mutates."""
|
|
probe = [
|
|
sys.executable,
|
|
"-c",
|
|
"import os;print(os.environ.get('PROBE_EXTRA','__missing__'))",
|
|
]
|
|
result = _run(probe, extra_env={"PROBE_EXTRA": "v2r2c2-gatew-provider-harness"})
|
|
assert result.returncode == 0
|
|
assert result.stdout.strip() == "v2r2c2-gatew-provider-harness"
|