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

allow filtering by response

This commit is contained in:
Ivan Malison
2016-01-11 15:53:04 -08:00
parent 8a5bf23d34
commit 50246791e3
2 changed files with 17 additions and 0 deletions

View File

@@ -100,6 +100,21 @@ def test_vcr_before_record_response_iterable():
assert mock_filter.call_count == 1
def test_before_record_response_as_filter():
request = Request('GET', '/', '', {})
response = object() # just can't be None
# Prevent actually saving the cassette
with mock.patch('vcr.cassette.save_cassette'):
filter_all = mock.Mock(return_value=None)
vcr = VCR(before_record_response=filter_all)
with vcr.use_cassette('test') as cassette:
cassette.append(request, response)
assert cassette.data == []e
assert not cassette.dirty
def test_vcr_path_transformer():
# Regression test for #199

View File

@@ -237,6 +237,8 @@ class Cassette(object):
if not request:
return
response = self._before_record_response(response)
if response is None:
return
self.data.append((request, response))
self.dirty = True