Skip to content

Make HTTP cache tests deterministic - #181

Closed
mariuszlipinski wants to merge 1 commit into
manusimidt:mainfrom
mariuszlipinski:fix/deterministic-http-cache-test
Closed

Make HTTP cache tests deterministic#181
mariuszlipinski wants to merge 1 commit into
manusimidt:mainfrom
mariuszlipinski:fix/deterministic-http-cache-test

Conversation

@mariuszlipinski

Copy link
Copy Markdown
Contributor

Summary

  • Replace the live W3Schools request with a mocked successful response while preserving cache-write, cache-hit, purge, and re-download assertions.
  • Add a deterministic request-pacing test with mocked time, sleep, and HTTP session behavior.
  • Keep production code unchanged.

Why

The existing cache test depends on a third-party endpoint that currently returns HTTP 403 to the default client on some machines. Retries make the suite slow, and the result reflects an external access policy rather than py-xbrl cache behavior.

Validation

  • ruff check tests/test_cache.py
  • ruff format --check tests/test_cache.py
  • mypy tests/test_cache.py --check-untyped-defs
  • pytest -q tests/test_cache.py — 2 passed
  • pytest -q tests/ — 12 passed

@mariuszlipinski

Copy link
Copy Markdown
Contributor Author

Superseded by #183. The deterministic test change is preserved there together with the Ruff 0.16 and mypy 2.3 compatibility fixes required for the combined CI matrix to pass.

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