From c03459e582ef2e3a7c8ef367d4c7ea13a74fea7f Mon Sep 17 00:00:00 2001 From: Hector Dearman Date: Sat, 21 Sep 2013 21:47:27 +0100 Subject: [PATCH] allow match_on to be passed as an argument VCR --- tests/integration/test_config.py | 11 +++++++++++ vcr/config.py | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_config.py b/tests/integration/test_config.py index 5816eef..1a4e47c 100644 --- a/tests/integration/test_config.py +++ b/tests/integration/test_config.py @@ -34,3 +34,14 @@ def test_override_set_cassette_library_dir(tmpdir): assert os.path.exists(str(tmpdir.join('subdir2').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 diff --git a/vcr/config.py b/vcr/config.py index aef77e7..76685e9 100644 --- a/vcr/config.py +++ b/vcr/config.py @@ -8,9 +8,11 @@ class VCR(object): def __init__(self, serializer='yaml', cassette_library_dir=None, - record_mode="once"): + record_mode="once", + match_on=['url','method'], + ): self.serializer = serializer - self.match_on = ['url', 'method'] + self.match_on = match_on self.cassette_library_dir = cassette_library_dir self.serializers = { 'yaml': yamlserializer,