"""Hardening test fixtures. Per-test isolation is STRUCTURAL, not via a reset hook: every test builds a fresh Flask app, so each gets its own ``memory://`` rate-limit store on ``app.extensions`` and its own breaker registry. There is no process-global hardening state to reset between tests; if one is ever introduced, add a real teardown here rather than relying on this comment. """ from pathlib import Path _HARDENING_TESTS_DIR = Path(__file__).parent def pytest_collection_modifyitems(items): """Mark every test in this subtree ``no_db`` so the root autouse app/DB fixtures opt out. These are pure unit tests -- they build their own Flask app (or none) and never touch the repo DB. Tagging by path (not by shadowing the root fixtures by name) keeps the opt-out robust if the root conftest renames or adds DB fixtures. """ for item in items: if _HARDENING_TESTS_DIR in Path(str(item.fspath)).parents: item.add_marker('no_db')