test: fix latent doctests + competitive suite, declare competitor test deps#178
Merged
Merged
Conversation
…t deps
Three latent hygiene issues, none caught by gating CI (it runs targeted
tests/unit+critical paths and --doctest-modules only over tests/, not src/):
1. Broken src doctests (failed under `pytest --doctest-modules src/`):
- backends/base.py: `RedisBackend()` needs DI/config, so the bare-construct
line raised and the isinstance check NameError'd. Use `issubclass(...)`,
which demonstrates the runtime-checkable protocol without a live backend.
- reliability/metrics_collection.py: doctest called a non-existent
`clear_metrics()`. Removed it — the assertion holds regardless of prior
state (no need to invent a function for one doctest).
2. Undeclared competitor deps: tests/competitive/ hard-imports cachetools and
aiocache but neither was declared, so the whole comparison suite failed to
collect. Declared both in [dependency-groups] dev.
3. Declaring the deps un-hid 3 bit-rotted competitive tests (test bugs, not
product regressions — verified):
- tuple/nested-tuple preservation asserted the old 'L1 serializes -> list'
behavior; cachekit's L1-only path now stores native objects, so tuples are
preserved (confirmed). Updated assertions + docstrings.
- test_cachekit_has_ttl used time_machine, which doesn't drive L1's
time.time() expiry in that path; switched to a real short sleep (L1 TTL
verified working with real time).
|
Caution Review failedPull request was closed or merged during review WalkthroughThis PR updates dev dependencies, clarifies documentation examples to match actual behaviour, and refactors competitive tests to assert that cachekit preserves tuple types in L1-only mode and to use real sleep-based timing for TTL validation instead of clock mocking. ChangesDependency, Documentation, and Test Updates
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hygiene sweep of three latent issues, none caught by gating CI (it runs targeted
tests/unit+tests/criticalpaths, and--doctest-modulesonly coverstests/, neversrc/).1. Broken
srcdoctestsFailed under
pytest --doctest-modules src/:backends/base.py—RedisBackend()requires DI/config, so bare construction raised and the follow-upisinstancelineNameErrord. Switched toissubclass(RedisBackend, BaseBackend), which demonstrates the runtime-checkable protocol without a live backend.reliability/metrics_collection.py— doctest called a non-existentclear_metrics(). Removed it; the"api_calls" in metricsassertion holds regardless of prior state (no need to invent a function for one doctest).2. Undeclared competitor test deps
tests/competitive/hard-importscachetoolsandaiocache, but neither was declared — the whole comparison suite failed to collect. Declared both in[dependency-groups] dev.3. Un-rotted 3 competitive tests (test bugs, not product regressions — verified)
Declaring the deps un-hid 3 bit-rotted tests:
backend=None) path now stores native object references (no serialization), so tuples are preserved. Updated assertions + docstrings to match (confirmed via direct probe).test_cachekit_has_ttlusedtime_machine, which does not drive L1'stime.time()expiry in that path. Switched to a real short sleep; L1 TTL itself is correct (verified with real time).Verification
pytest --doctest-modules src/cachekit/backends/base.py src/cachekit/reliability/metrics_collection.py-> 3 passed, 5 skippedpytest tests/competitive/-> 92 passed, 1 skipped (was: collection error)ruff check/formatclean;make type-checkscope issrconly (unaffected)Summary by CodeRabbit
Tests
Chores
Documentation