"""Outer conftest for the blackbox pytest tree. This file re-uses the runner-image conftest by re-exporting its hooks and fixtures. Inside the docker container the runner-image conftest is on the PYTHONPATH (via `/opt/e2e-runner/runner/conftest.py`); pytest discovers that conftest as the "rootdir" conftest because `pytest.ini` lives at `/opt/e2e-runner/`. The shim here exists so a developer can also point pytest at this directory directly (e.g., `pytest e2e/tests/positive/test_smoke.py`) when iterating outside docker — the shim adds the runner package to sys.path and re-imports everything. """ from __future__ import annotations import sys from pathlib import Path def _bootstrap_runner_path() -> None: """Make `runner.*` imports work when running outside the docker image.""" here = Path(__file__).resolve() # When inside the docker image, runner/ lives at /opt/e2e-runner/runner. # When iterating locally, runner/ lives at /e2e/runner. candidates = [ Path("/opt/e2e-runner"), here.parents[1], # e2e/ ] for c in candidates: if (c / "runner").is_dir(): if str(c) not in sys.path: sys.path.insert(0, str(c)) return _bootstrap_runner_path() # Re-export the runner conftest's hooks/fixtures so pytest picks them up # regardless of which conftest it discovers first. Star imports here are # the documented pytest pattern for conftest layering. from runner.conftest import * # noqa: F401,F403,E402 — pytest conftest re-export