Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/integration/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion vcr/cassette.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,12 @@ def _responses(self, request):

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):
"""
Expand Down