]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Fix issue #36 - error message for unregistered matcher was broken
authorKevin McCarthy <me@kevinmccarthy.org>
Mon, 30 Sep 2013 01:56:13 +0000 (15:56 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Mon, 30 Sep 2013 01:56:50 +0000 (15:56 -1000)
README.md
setup.py
tests/integration/test_config.py
tests/integration/test_wild.py
tests/unit/test_cassettes.py
vcr/config.py

index f71e5c2ad4aeb61fb753e87de4519b4f029dcf8c..d60fdf0ed37d636f62ab67786af28f377ece860a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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.
 
 ##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.
   Thanks, @chromy!
 * 0.3.1: Fix issue causing full paths to be sent on the HTTP request
index b6968970dcd2295ae2ae74274ab0f06113ef9aff..541f78addc7fcd3a078837473458647f3080f87d 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@ class PyTest(TestCommand):
         sys.exit(errno)
 
 setup(name='vcrpy',
-      version='0.3.2',
+      version='0.3.3',
       description="A Python port of Ruby's VCR to make mocking HTTP easier",
       author='Kevin McCarthy',
       author_email='me@kevinmccarthy.org',
index 1a4e47cef7ed54a47beb292917b1a7eb29c3b2c6..2d70968bb63b7a4790f5a6ffdc489fcea9d3edb4 100644 (file)
@@ -1,6 +1,7 @@
 import os
 import json
 import urllib2
+import pytest
 import vcr
 
 
@@ -45,3 +46,11 @@ def test_override_match_on(tmpdir):
 
     assert len(cass) == 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
index 167219d4bd44f54b510950f7ca2f0ea274b6a6c9..13f6caa842cfba51b0b945f3581185816b2d0b85 100644 (file)
@@ -46,6 +46,7 @@ def test_flickr_multipart_upload():
         _pretend_to_be_flickr_library()
         assert cass.play_count == 1
 
+
 def test_flickr_should_respond_with_200(tmpdir):
     testfile = str(tmpdir.join('flickr.yml'))
     with vcr.use_cassette(testfile):
index 0d5de4788dc0c1affc0fcbc024e974730ea1d676..df2e75579778de2e0a7210e68dcdb8ad3fa39c0a 100644 (file)
@@ -50,6 +50,7 @@ def test_cassette_len():
 def _mock_requests_match(request1, request2, matchers):
     return request1 == request2
 
+
 @mock.patch('vcr.cassette.requests_match', _mock_requests_match)
 def test_cassette_contains():
     a = Cassette('test')
index 76685e93497bb87b49e25b4d65d7d4bcf65ef22b..d8dd34791392cedfa5d684b04f906cf8eef203db 100644 (file)
@@ -9,7 +9,7 @@ class VCR(object):
                  serializer='yaml',
                  cassette_library_dir=None,
                  record_mode="once",
-                 match_on=['url','method'],
+                 match_on=['url', 'method'],
                  ):
         self.serializer = serializer
         self.match_on = match_on
@@ -42,10 +42,9 @@ class VCR(object):
         try:
             matchers = [self.matchers[m] for m in matcher_names]
         except KeyError:
-            print "Matcher {0} doesn't exist or isn't registered".format(
-                matcher_name
+            raise KeyError(
+                "Matcher {0} doesn't exist or isn't registered".format(m)
             )
-            raise KeyError
         return matchers
 
     def use_cassette(self, path, **kwargs):