Files
gps-denied-onboard/e2e/tests/conftest.py
T
Oleksandr Bezdieniezhnykh 43fdef1aac [AZ-595] Batch 75: sitl_observer FDR-replay + scenario probe cleanup
Implement all 11 `sitl_observer` public surfaces as an offline
FDR-replay strategy (reads JSON fixtures under `${E2E_SITL_REPLAY_DIR}`
instead of live pymavlink/yamspy). Replace 12 per-scenario
`_harness_helpers_implemented` probes with one shared session-scoped
`sitl_replay_ready` fixture in `e2e/tests/conftest.py`.

Net: -636 LoC of duplicated scenario gating, +17 LoC shared fixture,
+38 new unit tests (596 total, up from 558). Includes K=3 cumulative
review for batches 73-75 (PASS).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-17 09:00:55 +03:00

60 lines
2.1 KiB
Python

"""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 <repo>/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
import pytest # noqa: E402
from runner.helpers import sitl_observer # noqa: E402
@pytest.fixture(scope="session")
def sitl_replay_ready() -> bool:
"""True iff the FDR-replay fixture directory is configured + present.
AZ-595 replaces the per-scenario `_harness_helpers_implemented` probes
that passed `/tmp/non-existent` to each helper and inspected the
exception type. Scenarios should now consult this fixture and skip
cleanly when the SITL replay fixtures haven't been prepared (the
typical case during local unit runs that only exercise the helpers).
"""
return sitl_observer.replay_dir_available()