File size: 783 Bytes
c94194a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | """Shared pytest fixtures.
The validation engine defaults to a process-global Redis/in-memory cache so
results are reused across runs. That is correct in production but leaks state
between tests — one test's cached DNS/MX then satisfies the next test's
"resolution happened" assertion.
Clearing the in-memory tier between tests keeps the suite hermetic without
every test having to inject its own cache. Tests that assert on caching still
inject a recording cache explicitly.
"""
import pytest
@pytest.fixture(autouse=True)
def _clear_global_cache():
try:
from app.utils import cache as cache_mod
except Exception: # pragma: no cover - import guard
yield
return
cache_mod._memory_cache.clear()
yield
cache_mod._memory_cache.clear() |