mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 17:15:35 +00:00
Add a rewind method to reset a cassette.
This commit is contained in:
@@ -133,6 +133,17 @@ def test_cassette_all_played():
|
|||||||
assert a.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():
|
def test_before_record_response():
|
||||||
before_record_response = mock.Mock(return_value='mutated')
|
before_record_response = mock.Mock(return_value='mutated')
|
||||||
cassette = Cassette('test', before_record_response=before_record_response)
|
cassette = Cassette('test', before_record_response=before_record_response)
|
||||||
|
|||||||
@@ -287,6 +287,9 @@ class Cassette(object):
|
|||||||
% (self._path, request)
|
% (self._path, request)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def rewind(self):
|
||||||
|
self.play_counts = collections.Counter()
|
||||||
|
|
||||||
def _as_dict(self):
|
def _as_dict(self):
|
||||||
return {"requests": self.requests, "responses": self.responses}
|
return {"requests": self.requests, "responses": self.responses}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user