diff --git a/tests/unit/test_cassettes.py b/tests/unit/test_cassettes.py index e719156..4541530 100644 --- a/tests/unit/test_cassettes.py +++ b/tests/unit/test_cassettes.py @@ -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) diff --git a/vcr/cassette.py b/vcr/cassette.py index 5683ddf..79d8816 100644 --- a/vcr/cassette.py +++ b/vcr/cassette.py @@ -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}