1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

Add a rewind method to reset a cassette.

This commit is contained in:
Karim Hamidou
2018-12-20 12:44:07 +01:00
parent c74a857aa4
commit 472bc3aea1
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}