mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 09:13:23 +00:00
allow match_on to be passed as an argument VCR
This commit is contained in:
committed by
Kevin McCarthy
parent
912452e863
commit
c03459e582
@@ -34,3 +34,14 @@ def test_override_set_cassette_library_dir(tmpdir):
|
|||||||
|
|
||||||
assert os.path.exists(str(tmpdir.join('subdir2').join('test.json')))
|
assert os.path.exists(str(tmpdir.join('subdir2').join('test.json')))
|
||||||
assert not os.path.exists(str(tmpdir.join('subdir').join('test.json')))
|
assert not os.path.exists(str(tmpdir.join('subdir').join('test.json')))
|
||||||
|
|
||||||
|
|
||||||
|
def test_override_match_on(tmpdir):
|
||||||
|
my_vcr = vcr.VCR(match_on=['method'])
|
||||||
|
|
||||||
|
with my_vcr.use_cassette(str(tmpdir.join('test.json'))) as cass:
|
||||||
|
urllib2.urlopen('http://httpbin.org/')
|
||||||
|
urllib2.urlopen('http://httpbin.org/get')
|
||||||
|
|
||||||
|
assert len(cass) == 1
|
||||||
|
assert cass.play_count == 1
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ class VCR(object):
|
|||||||
def __init__(self,
|
def __init__(self,
|
||||||
serializer='yaml',
|
serializer='yaml',
|
||||||
cassette_library_dir=None,
|
cassette_library_dir=None,
|
||||||
record_mode="once"):
|
record_mode="once",
|
||||||
|
match_on=['url','method'],
|
||||||
|
):
|
||||||
self.serializer = serializer
|
self.serializer = serializer
|
||||||
self.match_on = ['url', 'method']
|
self.match_on = match_on
|
||||||
self.cassette_library_dir = cassette_library_dir
|
self.cassette_library_dir = cassette_library_dir
|
||||||
self.serializers = {
|
self.serializers = {
|
||||||
'yaml': yamlserializer,
|
'yaml': yamlserializer,
|
||||||
|
|||||||
Reference in New Issue
Block a user