Skip to content

Fix cross-test cache pollution in data pipeline tests - #110

Merged
belarusian merged 1 commit into
mainfrom
build24/cache-test-isolation
Aug 16, 2026
Merged

Fix cross-test cache pollution in data pipeline tests#110
belarusian merged 1 commit into
mainfrom
build24/cache-test-isolation

Conversation

@belarusian

Copy link
Copy Markdown
Owner

The disk cache was enabled by default during the full test suite, so decorated data-pipeline functions could read stale entries written by unrelated tests (the cache key incorporates the identity of injected mock clients, which is unstable across garbage collection). This caused test_data.py::test_decorated_fetch_strips_cache_valid to intermittently receive a cached price instead of the freshly computed one.

Changes:

  • Resolve settings per call in the cached() decorator so that changes to the settings singleton (e.g. cache_enabled toggled in tests) are respected rather than captured once at decoration time.
  • Add tests/conftest.py with an autouse fixture that disables the disk cache for the suite and pins cache.get_settings to the real function, undoing leaks from tests that reload alloc.lib.cache inside a patch block. Tests that exercise caching directly patch get_settings with their own fake and are unaffected.

Gate: 556 tests pass, ruff clean, mypy clean.

The disk cache was enabled by default during the full test suite, so
decorated data-pipeline functions could read stale entries written by
unrelated tests (the cache key incorporates the identity of injected
mock clients, which is unstable across garbage collection). This caused
test_data.py::test_decorated_fetch_strips_cache_valid to intermittently
receive a cached price instead of the freshly computed one.

- Resolve settings per call in the cached() decorator so that changes to
  the settings singleton (e.g. cache_enabled toggled in tests) are
  respected rather than captured once at decoration time.
- Add tests/conftest.py with an autouse fixture that disables the disk
  cache for the suite and pins cache.get_settings to the real function,
  undoing leaks from tests that reload alloc.lib.cache inside a patch
  block. Tests that exercise caching directly patch get_settings with
  their own fake and are unaffected.
@belarusian
belarusian merged commit e6ea349 into main Aug 16, 2026
1 check passed
@belarusian
belarusian deleted the build24/cache-test-isolation branch August 16, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant