]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Fix requests stub. Closes #94
authorKevin McCarthy <me@kevinmccarthy.org>
Tue, 2 Sep 2014 01:18:30 +0000 (15:18 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Tue, 2 Sep 2014 01:48:57 +0000 (15:48 -1000)
.travis.yml
tox.ini
vcr/patch.py
vcr/stubs/requests_stubs.py

index cb4679ccdcd69574eb01a737d42764313f227301..703b19bd56f09e1ff24a481354ca02dfb79b1dd9 100644 (file)
@@ -7,6 +7,7 @@ env:
   matrix:
     - WITH_LIB="requests2.2"
     - WITH_LIB="requests2.3"
+    - WITH_LIB="requests2.4"
     - WITH_LIB="requests1.x"
     - WITH_LIB="httplib2"
     - WITH_LIB="boto"
@@ -31,6 +32,7 @@ install:
 - if [ $WITH_LIB = "requests1.x" ] ; then pip install requests==1.2.3; fi
 - if [ $WITH_LIB = "requests2.2" ] ; then pip install requests==2.2.1; fi
 - if [ $WITH_LIB = "requests2.3" ] ; then pip install requests==2.3.0; fi
+- if [ $WITH_LIB = "requests2.4" ] ; then pip install requests==2.4.0; fi
 - if [ $WITH_LIB = "httplib2" ] ; then pip install httplib2; fi
 - if [ $WITH_LIB = "boto" ] ; then pip install boto; fi
 script: python setup.py test
diff --git a/tox.ini b/tox.ini
index 322802259a427816ba18a6909cfee95bb99c1cb3..bf7a840031fae0a7bf710d0a080748bb5090df1c 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -10,6 +10,10 @@ envlist =
     py33,
     py34,
     pypy,
+    py26requests24,
+    py27requests24,
+    py34requests24,
+    pypyrequests24,
     py26requests23,
     py27requests23,
     py34requests23,
@@ -73,6 +77,52 @@ deps =
     PyYAML
     requests==1.2.3
 
+[testenv:py26requests24]
+basepython = python2.6
+deps =
+    mock
+    pytest
+    pytest-localserver
+    PyYAML
+    requests==2.4.0
+
+[testenv:py27requests24]
+basepython = python2.7
+deps =
+    mock
+    pytest
+    pytest-localserver
+    PyYAML
+    requests==2.4.0
+
+[testenv:py33requests24]
+basepython = python3.4
+deps =
+    mock
+    pytest
+    pytest-localserver
+    PyYAML
+    requests==2.4.0
+
+[testenv:py34requests24]
+basepython = python3.4
+deps =
+    mock
+    pytest
+    pytest-localserver
+    PyYAML
+    requests==2.4.0
+
+[testenv:pypyrequests24]
+basepython = pypy
+deps =
+    mock
+    pytest
+    pytest-localserver
+    PyYAML
+    requests==2.4.0
+
+
 [testenv:py26requests23]
 basepython = python2.6
 deps =
index d46cec0c9106f541478a5c80724c33eabef34c13..2d40362d82a5fa5aa45edf5cce9d6ad807ebe16c 100644 (file)
@@ -56,15 +56,16 @@ def install(cassette):
     # patch requests v1.x
     try:
         import requests.packages.urllib3.connectionpool as cpool
-        from .stubs.requests_stubs import VCRVerifiedHTTPSConnection
-        cpool.VerifiedHTTPSConnection = VCRVerifiedHTTPSConnection
+        from .stubs.requests_stubs import VCRRequestsHTTPConnection, VCRRequestsHTTPSConnection
+        cpool.VerifiedHTTPSConnection = VCRRequestsHTTPSConnection
+        cpool.HTTPConnection = VCRRequestsHTTPConnection
         cpool.VerifiedHTTPSConnection.cassette = cassette
         cpool.HTTPConnection = VCRHTTPConnection
         cpool.HTTPConnection.cassette = cassette
     # patch requests v2.x
-        cpool.HTTPConnectionPool.ConnectionCls = VCRHTTPConnection
+        cpool.HTTPConnectionPool.ConnectionCls = VCRRequestsHTTPConnection
         cpool.HTTPConnectionPool.cassette = cassette
-        cpool.HTTPSConnectionPool.ConnectionCls = VCRHTTPSConnection
+        cpool.HTTPSConnectionPool.ConnectionCls = VCRRequestsHTTPSConnection
         cpool.HTTPSConnectionPool.cassette = cassette
     except ImportError:  # pragma: no cover
         pass
index f026fdc5945484e0265b814ee88d88eef98e8bd2..d0617122b184db3f4a67409102998f2ce2bd5bb9 100644 (file)
@@ -1,8 +1,13 @@
 '''Stubs for requests'''
 
-from requests.packages.urllib3.connectionpool import VerifiedHTTPSConnection
-from ..stubs import VCRHTTPSConnection
+from requests.packages.urllib3.connectionpool import HTTPConnection, VerifiedHTTPSConnection
+from ..stubs import VCRHTTPConnection, VCRHTTPSConnection
 
+# urllib3 defines its own HTTPConnection classes, which requests goes ahead and assumes
+# you're using.  It includes some polyfills for newer features missing in older pythons.
 
-class VCRVerifiedHTTPSConnection(VCRHTTPSConnection, VerifiedHTTPSConnection):
+class VCRRequestsHTTPConnection(VCRHTTPConnection, HTTPConnection):
+    _baseclass = HTTPConnection
+
+class VCRRequestsHTTPSConnection(VCRHTTPSConnection, VerifiedHTTPSConnection):
     _baseclass = VerifiedHTTPSConnection