1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-10 17:45:35 +00:00

Merge pull request #413 from khamidou/add_rewind_method

Add a `rewind` method to reset a cassette.
This commit is contained in:
Ivan Malison
2019-06-10 17:53:37 -07:00
committed by GitHub
2 changed files with 14 additions and 0 deletions

View File

@@ -133,6 +133,17 @@ def test_cassette_all_played():
assert a.all_played
@mock.patch('vcr.cassette.requests_match', _mock_requests_match)
def test_cassette_rewound():
a = Cassette('test')
a.append('foo', 'bar')
a.play_response('foo')
assert a.all_played
a.rewind()
assert not a.all_played
def test_before_record_response():
before_record_response = mock.Mock(return_value='mutated')
cassette = Cassette('test', before_record_response=before_record_response)

View File

@@ -287,6 +287,9 @@ class Cassette(object):
% (self._path, request)
)
def rewind(self):
self.play_counts = collections.Counter()
def _as_dict(self):
return {"requests": self.requests, "responses": self.responses}