mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
Drop support for botocore <1.11.0
This commit is contained in:
@@ -57,25 +57,6 @@ def get_user(iam_client):
|
|||||||
return _get_user
|
return _get_user
|
||||||
|
|
||||||
|
|
||||||
@boto3_skip_vendored_requests
|
|
||||||
def test_boto_vendored_stubs(tmpdir):
|
|
||||||
with vcr.use_cassette(str(tmpdir.join("boto3-stubs.yml"))):
|
|
||||||
# Perform the imports within the patched context so that
|
|
||||||
# HTTPConnection, VerifiedHTTPSConnection refers to the patched version.
|
|
||||||
from botocore.vendored.requests.packages.urllib3.connectionpool import (
|
|
||||||
HTTPConnection,
|
|
||||||
VerifiedHTTPSConnection,
|
|
||||||
)
|
|
||||||
|
|
||||||
from vcr.stubs.boto3_stubs import VCRRequestsHTTPConnection, VCRRequestsHTTPSConnection
|
|
||||||
|
|
||||||
# Prove that the class was patched by the stub and that we can instantiate it.
|
|
||||||
assert issubclass(HTTPConnection, VCRRequestsHTTPConnection)
|
|
||||||
assert issubclass(VerifiedHTTPSConnection, VCRRequestsHTTPSConnection)
|
|
||||||
HTTPConnection("hostname.does.not.matter")
|
|
||||||
VerifiedHTTPSConnection("hostname.does.not.matter")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
os.environ.get("TRAVIS_PULL_REQUEST") != "false",
|
os.environ.get("TRAVIS_PULL_REQUEST") != "false",
|
||||||
reason="Encrypted Environment Variables from Travis Repository Settings"
|
reason="Encrypted Environment Variables from Travis Repository Settings"
|
||||||
|
|||||||
40
vcr/patch.py
40
vcr/patch.py
@@ -16,15 +16,16 @@ _HTTPSConnection = httplib.HTTPSConnection
|
|||||||
# Try to save the original types for boto3
|
# Try to save the original types for boto3
|
||||||
try:
|
try:
|
||||||
from botocore.awsrequest import AWSHTTPConnection, AWSHTTPSConnection
|
from botocore.awsrequest import AWSHTTPConnection, AWSHTTPSConnection
|
||||||
except ImportError:
|
except ImportError as e:
|
||||||
try:
|
try:
|
||||||
import botocore.vendored.requests.packages.urllib3.connectionpool as cpool
|
import botocore.vendored.requests # noqa: F401
|
||||||
except ImportError: # pragma: no cover
|
except ImportError: # pragma: no cover
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
_Boto3VerifiedHTTPSConnection = cpool.VerifiedHTTPSConnection
|
raise RuntimeError(
|
||||||
_cpoolBoto3HTTPConnection = cpool.HTTPConnection
|
"vcrpy >=4.2.2 and botocore <1.11.0 are not compatible"
|
||||||
_cpoolBoto3HTTPSConnection = cpool.HTTPSConnection
|
"; please upgrade botocore (or downgrade vcrpy)"
|
||||||
|
) from e
|
||||||
else:
|
else:
|
||||||
_Boto3VerifiedHTTPSConnection = AWSHTTPSConnection
|
_Boto3VerifiedHTTPSConnection = AWSHTTPSConnection
|
||||||
_cpoolBoto3HTTPConnection = AWSHTTPConnection
|
_cpoolBoto3HTTPConnection = AWSHTTPConnection
|
||||||
@@ -203,15 +204,7 @@ class CassettePatcherBuilder:
|
|||||||
# botocore using awsrequest
|
# botocore using awsrequest
|
||||||
import botocore.awsrequest as cpool
|
import botocore.awsrequest as cpool
|
||||||
except ImportError: # pragma: no cover
|
except ImportError: # pragma: no cover
|
||||||
try:
|
pass
|
||||||
# botocore using vendored requests
|
|
||||||
import botocore.vendored.requests.packages.urllib3.connectionpool as cpool
|
|
||||||
except ImportError: # pragma: no cover
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
from .stubs import boto3_stubs
|
|
||||||
|
|
||||||
yield self._urllib3_patchers(cpool, boto3_stubs)
|
|
||||||
else:
|
else:
|
||||||
from .stubs import boto3_stubs
|
from .stubs import boto3_stubs
|
||||||
|
|
||||||
@@ -460,24 +453,7 @@ def reset_patchers():
|
|||||||
# unpatch botocore with awsrequest
|
# unpatch botocore with awsrequest
|
||||||
import botocore.awsrequest as cpool
|
import botocore.awsrequest as cpool
|
||||||
except ImportError: # pragma: no cover
|
except ImportError: # pragma: no cover
|
||||||
try:
|
pass
|
||||||
# unpatch botocore with vendored requests
|
|
||||||
import botocore.vendored.requests.packages.urllib3.connectionpool as cpool
|
|
||||||
except ImportError: # pragma: no cover
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# unpatch requests v1.x
|
|
||||||
yield mock.patch.object(cpool, "VerifiedHTTPSConnection", _Boto3VerifiedHTTPSConnection)
|
|
||||||
yield mock.patch.object(cpool, "HTTPConnection", _cpoolBoto3HTTPConnection)
|
|
||||||
# unpatch requests v2.x
|
|
||||||
if hasattr(cpool.HTTPConnectionPool, "ConnectionCls"):
|
|
||||||
yield mock.patch.object(cpool.HTTPConnectionPool, "ConnectionCls", _cpoolBoto3HTTPConnection)
|
|
||||||
yield mock.patch.object(
|
|
||||||
cpool.HTTPSConnectionPool, "ConnectionCls", _cpoolBoto3HTTPSConnection
|
|
||||||
)
|
|
||||||
|
|
||||||
if hasattr(cpool, "HTTPSConnection"):
|
|
||||||
yield mock.patch.object(cpool, "HTTPSConnection", _cpoolBoto3HTTPSConnection)
|
|
||||||
else:
|
else:
|
||||||
if hasattr(cpool.AWSHTTPConnectionPool, "ConnectionCls"):
|
if hasattr(cpool.AWSHTTPConnectionPool, "ConnectionCls"):
|
||||||
yield mock.patch.object(cpool.AWSHTTPConnectionPool, "ConnectionCls", _cpoolBoto3HTTPConnection)
|
yield mock.patch.object(cpool.AWSHTTPConnectionPool, "ConnectionCls", _cpoolBoto3HTTPConnection)
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
"""Stubs for boto3"""
|
"""Stubs for boto3"""
|
||||||
try:
|
from botocore.awsrequest import AWSHTTPConnection as HTTPConnection
|
||||||
# boto using awsrequest
|
from botocore.awsrequest import AWSHTTPSConnection as VerifiedHTTPSConnection
|
||||||
from botocore.awsrequest import AWSHTTPConnection as HTTPConnection
|
|
||||||
from botocore.awsrequest import AWSHTTPSConnection as VerifiedHTTPSConnection
|
|
||||||
|
|
||||||
except ImportError: # pragma: nocover
|
|
||||||
# boto using vendored requests
|
|
||||||
# urllib3 defines its own HTTPConnection classes, which boto3 goes ahead and assumes
|
|
||||||
# you're using. It includes some polyfills for newer features missing in older pythons.
|
|
||||||
try:
|
|
||||||
from urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
|
|
||||||
except ImportError: # pragma: nocover
|
|
||||||
from requests.packages.urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
|
|
||||||
|
|
||||||
from ..stubs import VCRHTTPConnection, VCRHTTPSConnection
|
from ..stubs import VCRHTTPConnection, VCRHTTPSConnection
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user