Files
hermes-agent/tests/scripts/test_check_compat_pointers.py
ethernet 06da1225e6 test: pin merged-from-main tests to this branch's contracts
hermes_yaml (ruamel, YAML 1.2) raises its own YAMLError and needs a quoted
URL in flow mappings; the pre-argparse interface probe in main.py is an
allowlisted raw config read; the compat-pointer walker forwards onerror;
tools/lazy_deps.py is a retirement shim with no uv call site; _self stays on
the frozen old-updater surface; the tzdata marker also carries the Python floor.
2026-09-19 04:15:04 -04:00

51 lines
1.7 KiB
Python

"""The compatibility-pointer scanner only traverses first-party Python trees."""
import importlib.util
import os
from pathlib import Path
SCRIPT = Path(__file__).resolve().parents[2] / "scripts" / "check_compat_pointers.py"
def _load():
spec = importlib.util.spec_from_file_location("check_compat_pointers", SCRIPT)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
def test_py_files_prunes_dependency_trees_before_descent(tmp_path, monkeypatch):
mod = _load()
(tmp_path / "package").mkdir()
(tmp_path / "package" / "source.py").write_text("VALUE = 1\n", encoding="utf-8")
(tmp_path / "package" / "apps").mkdir()
(tmp_path / "package" / "apps" / "nested.py").write_text("VALUE = 3\n", encoding="utf-8")
excluded = [
tmp_path / ".venv",
tmp_path / "venv",
tmp_path / "node_modules",
tmp_path / "package" / "__pycache__",
tmp_path / "package" / "node_modules",
]
for directory in excluded:
directory.mkdir(parents=True)
(directory / "dependency.py").write_text("VALUE = 2\n", encoding="utf-8")
visited = []
real_walk = os.walk
def tracking_walk(root, **kwargs):
for dirpath, dirnames, filenames in real_walk(root, **kwargs):
visited.append(Path(dirpath))
yield dirpath, dirnames, filenames
monkeypatch.setattr(mod, "ROOT", tmp_path)
monkeypatch.setattr(mod.os, "walk", tracking_walk)
assert set(mod._py_files()) == {
tmp_path / "package" / "source.py",
tmp_path / "package" / "apps" / "nested.py",
}
assert tmp_path in visited
assert not set(excluded) & set(visited)