diff --git a/README.md b/README.md index 26b85b5..638db4d 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ my_vcr = vcr.VCR( serializer = 'json', cassette_library_dir = 'fixtures/cassettes', record_mode = 'once', - match_on = ['url', 'method'], + match_on = ['uri', 'method'], ) with my_vcr.use_cassette('test.json'): diff --git a/tests/integration/test_matchers.py b/tests/integration/test_matchers.py index c4b7999..007a844 100644 --- a/tests/integration/test_matchers.py +++ b/tests/integration/test_matchers.py @@ -25,18 +25,18 @@ def test_method_matcher(cassette): urlopen('http://httpbin.org/post', data=b'') # is a POST request -def test_url_matcher(cassette): +def test_uri_matcher(cassette): # prepare cassete - with vcr.use_cassette(cassette, match_on=['url']) as cass: + with vcr.use_cassette(cassette, match_on=['uri']) as cass: urlopen('http://httpbin.org/get?p1=q1&p2=q2') assert len(cass) == 1 - # play cassette with matching on url - with vcr.use_cassette(cassette, match_on=['url']) as cass: + # play cassette with matching on uri + with vcr.use_cassette(cassette, match_on=['uri']) as cass: urlopen('http://httpbin.org/get?p1=q1&p2=q2') assert cass.play_count == 1 - # should fail if url does not match + # should fail if uri does not match with pytest.raises(vcr.errors.CannotOverwriteExistingCassetteException): - with vcr.use_cassette(cassette, match_on=['url']) as cass: + with vcr.use_cassette(cassette, match_on=['uri']) as cass: urlopen('http://httpbin.org/get?p2=q2&p1=q1') diff --git a/tests/unit/test_matchers.py b/tests/unit/test_matchers.py index ae29c8a..0d53fd7 100644 --- a/tests/unit/test_matchers.py +++ b/tests/unit/test_matchers.py @@ -26,9 +26,9 @@ def assert_matcher(matcher_name): assert matched -def test_url_matcher(): +def test_uri_matcher(): for k1, k2 in itertools.permutations(REQUESTS, 2): - matched = matchers.url(REQUESTS[k1], REQUESTS[k2]) + matched = matchers.uri(REQUESTS[k1], REQUESTS[k2]) if set((k1, k2)) != set(('base', 'method')): assert not matched else: diff --git a/vcr/cassette.py b/vcr/cassette.py index df6a64b..f71bf03 100644 --- a/vcr/cassette.py +++ b/vcr/cassette.py @@ -13,7 +13,7 @@ from .patch import install, reset from .persist import load_cassette, save_cassette from .filters import filter_request from .serializers import yamlserializer -from .matchers import requests_match, url, method +from .matchers import requests_match, uri, method from .errors import UnhandledHTTPRequestError @@ -31,7 +31,7 @@ class Cassette(ContextDecorator): path, serializer=yamlserializer, record_mode='once', - match_on=[url, method], + match_on=[uri, method]): filter_headers=[], filter_query_parameters=[], before_record=None, diff --git a/vcr/config.py b/vcr/config.py index 8feb0c2..e8848ff 100644 --- a/vcr/config.py +++ b/vcr/config.py @@ -30,7 +30,8 @@ class VCR(object): } self.matchers = { 'method': matchers.method, - 'url': matchers.url, + 'uri': matchers.uri, + 'url': matchers.uri, # matcher for backwards compatibility 'scheme': matchers.scheme, 'host': matchers.host, 'port': matchers.method, diff --git a/vcr/matchers.py b/vcr/matchers.py index 1918652..c471538 100644 --- a/vcr/matchers.py +++ b/vcr/matchers.py @@ -5,8 +5,8 @@ def method(r1, r2): return r1.method == r2.method -def url(r1, r2): - return r1.url == r2.url +def uri(r1, r2): + return r1.uri == r2.uri def host(r1, r2):