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'):
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')
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:
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
path,
serializer=yamlserializer,
record_mode='once',
- match_on=[url, method],
+ match_on=[uri, method]):
filter_headers=[],
filter_query_parameters=[],
before_record=None,
}
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,
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):