mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-08-01 13:12:18 +00:00
Clear shared IP cache in parallel test setUp for isolation (#866)
tests/test_parallel.py's parity test compares sequential parse_report_file(path, offline=True) results in the parent process against results from cold worker processes. When the full suite runs locally (GITHUB_ACTIONS unset), tests/test_init.py runs first with real DNS lookups and warms the shared module-level parsedmarc.IP_ADDRESS_CACHE; get_ip_address_info consults the cache before honoring offline, so the sequential baseline returned DNS-enriched entries (e.g. reverse_dns='smtp7.cardinal.com') while the workers correctly returned None, failing the test. CI never sees this because it runs offline from the start. Clear the cache in _ParallelTestCase.setUp so baselines and workers both start cold. Test-only change; the cache-before-offline ordering in utils.py is intentional (a cache hit makes no network queries). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
483ae8112d
commit
5c7f4ba048
@@ -47,7 +47,8 @@ class _CountingIterable:
|
||||
|
||||
|
||||
class _ParallelTestCase(unittest.TestCase):
|
||||
"""Common env setup shared by parallel.py tests: offline mode, no DNS."""
|
||||
"""Common env setup shared by parallel.py tests: offline mode, no DNS,
|
||||
and a cold IP address cache."""
|
||||
|
||||
def setUp(self):
|
||||
self._env_patcher = patch.dict(
|
||||
@@ -55,6 +56,13 @@ class _ParallelTestCase(unittest.TestCase):
|
||||
)
|
||||
self._env_patcher.start()
|
||||
self.addCleanup(self._env_patcher.stop)
|
||||
# Earlier test modules (e.g. tests/test_init.py) may run with DNS
|
||||
# enabled locally and warm the shared module-level
|
||||
# parsedmarc.IP_ADDRESS_CACHE. get_ip_address_info consults the
|
||||
# cache before the offline check, so a warm cache would leak
|
||||
# DNS-enriched entries into offline parses run in this process
|
||||
# while spawned workers start cold, breaking parity.
|
||||
parsedmarc.IP_ADDRESS_CACHE.clear()
|
||||
|
||||
|
||||
class TestParallelMapParseReportFile(_ParallelTestCase):
|
||||
|
||||
Reference in New Issue
Block a user