# Ensure the project root is on sys.path so that test modules can import # top-level packages (app, amqp, cluster, config, …) without PYTHONPATH hacks. import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) """Shared pytest fixtures. All test modules manipulate in-process globals (sessions, rate buckets, cluster registry, eviction log). An autouse fixture resets every global before each test so no state leaks between tests, regardless of whether an individual test file remembers to clear it. """ import pytest import cluster import routers.chat from eviction import EVICTION_LOG from security import SESSIONS, PIN_ATTEMPTS, RATE_EVENTS @pytest.fixture(autouse=True) def _reset_global_state(): SESSIONS.clear() PIN_ATTEMPTS.clear() RATE_EVENTS.clear() cluster.CLUSTER_NODES.clear() cluster.CLUSTER_EVENTS.clear() cluster.CLUSTER_COORDINATOR = None cluster._pending_pings.clear() EVICTION_LOG.clear() routers.chat._ingest_tasks.clear() yield