Fix cache entries being lost when multiple tests share cassette#13
Closed
Fix cache entries being lost when multiple tests share cassette#13
Conversation
When multiple tests use the same default cassette file with RECORD_MODE=all, each test would create a new Cache instance with empty entries, causing subsequent tests to overwrite entries from earlier tests. Changes: - Load existing cassette entries in ALL mode before recording (cache.py:116-120) - Replace duplicate entries instead of appending when re-recording (cache.py:227-232) This ensures entries from all tests are preserved while still allowing re-recording of individual instructions. https://claude.ai/code/session_01PXyXZNXxqTusmww6BdzqkF
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
Fixed a bug where cache entries from one test would be lost when another test using the same cassette file ran in
RECORD_MODE=all. The issue occurred because each cache instance would clear existing entries instead of preserving them.Changes
put()method to replace existing entries with the same instruction and method (supporting re-recording) instead of always appending, preventing duplicates.Implementation Details
RECORD_MODE=alland a cassette exists,cache._load()is now called to preserve existing entries before recording new onesput()method now checks for existing entries matching both instruction and method, replacing them in-place rather than appendingsave()to persist changeshttps://claude.ai/code/session_01PXyXZNXxqTusmww6BdzqkF