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.
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