]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Add a failing test to illustrate a hole in vcrpy's Boto support
authorChris Marusich <marusich@users.noreply.github.com>
Thu, 3 Apr 2014 19:08:41 +0000 (12:08 -0700)
committerChris Marusich <marusich@users.noreply.github.com>
Thu, 3 Apr 2014 20:21:33 +0000 (13:21 -0700)
This test will fail with the following error:

TypeError: unbound method __init__() must be called with VCRHTTPConnection
instance as first argument (got CertValidatingHTTPSConnection instance instead)

The TypeError is raised because the __init__ method of Boto's
CertValidatingHTTPSConnection (which extends httplib.HTTPConnection) calls
httplib.HTTPConnection.__init__, and during the test httplib.HTTPConnection
actually refers to the patched verison (i.e., VCRHTTPConnection).  When
VCRHTTPConnection.__init__ is called, it expects to receive a
VCRHTTPConnection object as its first argument, but instead it receives a
CertValidatingHTTPSConnection object.  Because the only ancestor class of
CertValidatingHTTPSConnection is the original, un-patched
httplib.HTTPConnection, the first argument is not considered to be a
VCRHTTPConnection object, so a TypeError is raised.

tests/integration/test_boto.py

index 567a468d300219d3b03e0fe74de8d13c9b4fe914..ca6fb954378a52657f97ca400ca1d77fff569724 100644 (file)
@@ -4,6 +4,13 @@ from boto.s3.connection import S3Connection
 from boto.s3.key import Key
 import vcr
 
+def test_boto_stubs(tmpdir):
+    with vcr.use_cassette(str(tmpdir.join('boto-stubs.yml'))):
+        # Perform the imports within the patched context so that
+        # CertValidatingHTTPSConnection refers to the patched version.
+        from boto.https_connection import CertValidatingHTTPSConnection
+        CertValidatingHTTPSConnection('hostname.does.not.matter')
+
 def test_boto_without_vcr():
     s3_conn = S3Connection()
     s3_bucket = s3_conn.get_bucket('boto-demo-1394171994') # a bucket you can access