mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-10 17:45:35 +00:00
Fix issue #36 - error message for unregistered matcher was broken
This commit is contained in:
@@ -259,6 +259,8 @@ This library is a work in progress, so the API might change on you.
|
|||||||
There are probably some [bugs](https://github.com/kevin1024/vcrpy/issues?labels=bug&page=1&state=open) floating around too.
|
There are probably some [bugs](https://github.com/kevin1024/vcrpy/issues?labels=bug&page=1&state=open) floating around too.
|
||||||
|
|
||||||
##Changelog
|
##Changelog
|
||||||
|
* 0.3.3: Bugfix for error message when an unreigstered custom matcher
|
||||||
|
was used
|
||||||
* 0.3.2: Fix issue with new config syntax and the `match_on` parameter.
|
* 0.3.2: Fix issue with new config syntax and the `match_on` parameter.
|
||||||
Thanks, @chromy!
|
Thanks, @chromy!
|
||||||
* 0.3.1: Fix issue causing full paths to be sent on the HTTP request
|
* 0.3.1: Fix issue causing full paths to be sent on the HTTP request
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -19,7 +19,7 @@ class PyTest(TestCommand):
|
|||||||
sys.exit(errno)
|
sys.exit(errno)
|
||||||
|
|
||||||
setup(name='vcrpy',
|
setup(name='vcrpy',
|
||||||
version='0.3.2',
|
version='0.3.3',
|
||||||
description="A Python port of Ruby's VCR to make mocking HTTP easier",
|
description="A Python port of Ruby's VCR to make mocking HTTP easier",
|
||||||
author='Kevin McCarthy',
|
author='Kevin McCarthy',
|
||||||
author_email='me@kevinmccarthy.org',
|
author_email='me@kevinmccarthy.org',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import urllib2
|
import urllib2
|
||||||
|
import pytest
|
||||||
import vcr
|
import vcr
|
||||||
|
|
||||||
|
|
||||||
@@ -45,3 +46,11 @@ def test_override_match_on(tmpdir):
|
|||||||
|
|
||||||
assert len(cass) == 1
|
assert len(cass) == 1
|
||||||
assert cass.play_count == 1
|
assert cass.play_count == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_missing_matcher():
|
||||||
|
my_vcr = vcr.VCR()
|
||||||
|
my_vcr.register_matcher("awesome", object)
|
||||||
|
with pytest.raises(KeyError):
|
||||||
|
with my_vcr.use_cassette("test.yaml", match_on=['notawesome']):
|
||||||
|
pass
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ def test_flickr_multipart_upload():
|
|||||||
_pretend_to_be_flickr_library()
|
_pretend_to_be_flickr_library()
|
||||||
assert cass.play_count == 1
|
assert cass.play_count == 1
|
||||||
|
|
||||||
|
|
||||||
def test_flickr_should_respond_with_200(tmpdir):
|
def test_flickr_should_respond_with_200(tmpdir):
|
||||||
testfile = str(tmpdir.join('flickr.yml'))
|
testfile = str(tmpdir.join('flickr.yml'))
|
||||||
with vcr.use_cassette(testfile):
|
with vcr.use_cassette(testfile):
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ def test_cassette_len():
|
|||||||
def _mock_requests_match(request1, request2, matchers):
|
def _mock_requests_match(request1, request2, matchers):
|
||||||
return request1 == request2
|
return request1 == request2
|
||||||
|
|
||||||
|
|
||||||
@mock.patch('vcr.cassette.requests_match', _mock_requests_match)
|
@mock.patch('vcr.cassette.requests_match', _mock_requests_match)
|
||||||
def test_cassette_contains():
|
def test_cassette_contains():
|
||||||
a = Cassette('test')
|
a = Cassette('test')
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class VCR(object):
|
|||||||
serializer='yaml',
|
serializer='yaml',
|
||||||
cassette_library_dir=None,
|
cassette_library_dir=None,
|
||||||
record_mode="once",
|
record_mode="once",
|
||||||
match_on=['url','method'],
|
match_on=['url', 'method'],
|
||||||
):
|
):
|
||||||
self.serializer = serializer
|
self.serializer = serializer
|
||||||
self.match_on = match_on
|
self.match_on = match_on
|
||||||
@@ -42,10 +42,9 @@ class VCR(object):
|
|||||||
try:
|
try:
|
||||||
matchers = [self.matchers[m] for m in matcher_names]
|
matchers = [self.matchers[m] for m in matcher_names]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print "Matcher {0} doesn't exist or isn't registered".format(
|
raise KeyError(
|
||||||
matcher_name
|
"Matcher {0} doesn't exist or isn't registered".format(m)
|
||||||
)
|
)
|
||||||
raise KeyError
|
|
||||||
return matchers
|
return matchers
|
||||||
|
|
||||||
def use_cassette(self, path, **kwargs):
|
def use_cassette(self, path, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user