Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to remove unused requests from cassette #763

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

danielnsilva
Copy link

This PR adds an option to remove previously recorded interactions if they are not used. I believe this feature can address the issue discussed in #208. We don't need to focus on ignoring all requests in the cassette file, but instead, we can write to file only replayed interactions and new ones. If no previous request is used, VCR will save only new interactions.

There is a similar feature in Ruby VCR.

Replaces #677

Introduce the `drop_unused_requests` option (False by default). If True, it will force the `Cassette` saving operation with only played old interactions and new ones if they exist. As a result, unused old requests are dropped.

Add `_old_interactions`, `_played_interactions` and `_new_interactions()`.  The `_old_interactions` are previously recorded interactions loaded from Cassette files. The `_played_interactions` is a set of old interactions that were marked as played.  A new interaction is a tuple (request, response) in `self.data` that is not in `_old_interactions` list.
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