]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Fallback to importing from urllib3
authorJohn Vandenberg <jayvdb@gmail.com>
Thu, 15 Oct 2015 03:56:30 +0000 (14:56 +1100)
committerJohn Vandenberg <jayvdb@gmail.com>
Thu, 15 Oct 2015 03:56:30 +0000 (14:56 +1100)
requests.packages.urllib3 may be literally urllib3
instead of vendored urllib3.

vcr/stubs/requests_stubs.py

index d0617122b184db3f4a67409102998f2ce2bd5bb9..30e960f7a2d43ab8f0ab1e9dcb5173714bd4dd0d 100644 (file)
@@ -1,6 +1,10 @@
 '''Stubs for requests'''
 
-from requests.packages.urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
+try:
+    from requests.packages.urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
+except ImportError:
+    from urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
+
 from ..stubs import VCRHTTPConnection, VCRHTTPSConnection
 
 # urllib3 defines its own HTTPConnection classes, which requests goes ahead and assumes