Fix flaky cache-timing test with a ratio-based assertion#220
Merged
Conversation
test_repeated_access_is_cached compared against a fixed 10ms wall-clock budget, which flaked on CI runners where cached access alone took ~10.0-10.2ms (PR #219). Instead, measure the uncached build cost on the same machine and assert cached access is an order of magnitude faster, so the test scales with runner speed instead of racing a fixed clock. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #220 +/- ##
=======================================
Coverage 97.11% 97.11%
=======================================
Files 13 13
Lines 797 797
=======================================
Hits 774 774
Misses 23 23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
test_repeated_access_is_cachedcompared 10,000 cached-property accesses against a fixed 10ms wall-clock budget, which flaked on CI runners (observed 10.0-10.2ms in PR Add Codecov coverage reporting and README badges #219 on both Python 3.10 and 3.13)Constants()instances) and assert cached access is at least an order of magnitude fasterTest plan
uv run pytest tests/test_constants.py::SuffixesPrefixesTitlesPerformanceTests -vpassesuv run pytest(1310 passed, 22 xfailed)_pstcache innameparser/config/__init__.pyand confirmed the test fails (caught by the pre-existing identity assertion), then reverted