From 20ff2e9d9ae53e5614a47c89d527e359a281574b Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Thu, 3 Apr 2014 12:08:41 -0700 Subject: [PATCH] Add a failing test to illustrate a hole in vcrpy's Boto support 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/integration/test_boto.py b/tests/integration/test_boto.py index 567a468..ca6fb95 100644 --- a/tests/integration/test_boto.py +++ b/tests/integration/test_boto.py @@ -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