]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Replaced 'url' mather with 'uri'.
authorMax Shytikov <mshytikov@gmail.com>
Thu, 10 Apr 2014 23:32:10 +0000 (01:32 +0200)
committerMax Shytikov <mshytikov@gmail.com>
Wed, 30 Apr 2014 00:31:11 +0000 (02:31 +0200)
README.md
tests/integration/test_matchers.py
tests/unit/test_matchers.py
vcr/cassette.py
vcr/config.py
vcr/matchers.py

index 26b85b5bbf08013cb02d965662ac0cf276bb195a..638db4d2c6ffa8cc215ac97a051fd5fcaf184d78 100644 (file)
--- 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'):
index c4b799932a5b488bdcdc488d03b138c043487cbc..007a844b0e31fda4986eda083d6598e771276dd8 100644 (file)
@@ -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')
index ae29c8a4946e245ca224850e5b7235ca5da6adde..0d53fd75f1c9d444a2772c43a6b925fdde210567 100644 (file)
@@ -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:
index df6a64b9fb6788edfc48fe5b0d86c0aea8ca8bef..f71bf03ec48a31ac8d985b82083673ce81db8768 100644 (file)
@@ -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,
index 8feb0c2b2f773a3eb5ebe87d43454d2bff5f6849..e8848ff58b23d173b63a9263364e26b613af7b4e 100644 (file)
@@ -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,
index 19186528af816720a1e85773ebc02a484ab73c6f..c471538f7fb400dd15ea67c268c0352e13a52c4b 100644 (file)
@@ -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):