"""Test-process isolation for persistent runtime state.""" from __future__ import annotations import os import shutil import sys import tempfile from pathlib import Path # curry_store constructs its SQLite singleton during test collection. Point it # at a per-run directory before any test module imports synapse, so the release # gate is repeatable and never writes test constants into the checkout's live # data/curry.db. _TEST_STATE = Path(tempfile.mkdtemp(prefix="nexus-pytest-")) os.environ["NEXUS_CURRY_DB"] = str(_TEST_STATE / "curry.db") def pytest_sessionfinish(session, exitstatus): module = sys.modules.get("synapse.curry_store") if module is not None: module.curry_db.close() shutil.rmtree(_TEST_STATE, ignore_errors=True)