"""Portability regressions for drift baseline subprocess handoff.""" from __future__ import annotations import json import os import sys from pathlib import Path from types import SimpleNamespace from unittest.mock import patch REPO_ROOT = Path(__file__).resolve().parents[1] SCRIPTS_DIR = REPO_ROOT / "scripts" if str(SCRIPTS_DIR) not in sys.path: sys.path.insert(0, str(SCRIPTS_DIR)) import drift_baseline # noqa: E402 def test_fetch_page_data_uses_tempfile_not_dev_stdout_or_stdin() -> None: calls: list[tuple[list[str], dict]] = [] temp_paths: list[Path] = [] def fake_run(cmd: list[str], **kwargs): calls.append((cmd, kwargs)) assert kwargs["encoding"] == "utf-8" assert kwargs["errors"] == "replace" if cmd[1].endswith("fetch_page.py"): assert "/dev/stdout" not in cmd output_path = Path(cmd[cmd.index("--output") + 1]) temp_paths.append(output_path) output_path.write_bytes(b"