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

Compare commits

...

1 Commits

Author SHA1 Message Date
pyoor
0ccd772822 Ignore rewind when allow_playback_repeats is enabled 2025-12-10 14:31:52 -05:00
2 changed files with 16 additions and 1 deletions

View File

@@ -310,3 +310,13 @@ def test_post_unicode_match_on_body(tmpdir, httpbin_both):
req2 = requests.post(url, data).content
assert req1 == req2
def test_duplicate_get_allow_playback_repeats(tmpdir, httpbin_both):
"""Ensure that duplicate requests are not included in the cassette on record."""
with vcr.use_cassette(str(tmpdir.join("allow_repeats.yaml")), allow_playback_repeats=True) as cass:
requests.get(httpbin_both + "/same")
requests.get(httpbin_both + "/different")
requests.get(httpbin_both + "/same")
assert len(cass) == 2

View File

@@ -253,7 +253,12 @@ class Cassette:
def can_play_response_for(self, request):
request = self._before_record_request(request)
return request and request in self and self.record_mode != RecordMode.ALL and self.rewound
return (
request
and request in self
and self.record_mode != RecordMode.ALL
and (self.rewound or self.allow_playback_repeats)
)
def play_response(self, request):
"""