From 97473bb8d8fedeb0365b4c003273d645ae208651 Mon Sep 17 00:00:00 2001 From: Derek Bekoe Date: Mon, 23 Jan 2017 14:54:26 -0800 Subject: [PATCH 1/7] Correctly patch HTTPConnection.request in Python 3.6 Fixes https://github.com/kevin1024/vcrpy/issues/293 --- vcr/stubs/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcr/stubs/__init__.py b/vcr/stubs/__init__.py index 4518243..c12e194 100644 --- a/vcr/stubs/__init__.py +++ b/vcr/stubs/__init__.py @@ -153,7 +153,7 @@ class VCRConnection(object): ) return uri.replace(prefix, '', 1) - def request(self, method, url, body=None, headers=None): + def request(self, method, url, body=None, headers=None, *args, **kwargs): '''Persist the request metadata in self._vcr_request''' self._vcr_request = Request( method=method, From 24b617a427e174aedb0acca6690bb163f51baf2c Mon Sep 17 00:00:00 2001 From: Derek Bekoe Date: Tue, 24 Jan 2017 13:57:37 -0800 Subject: [PATCH 2/7] Add Python 3.6 to CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b76b624..ee6caf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,6 +54,7 @@ python: - 3.3 - 3.4 - 3.5 +- 3.6 - pypy - pypy3 install: From 091b4025948a81b9e81e4fa49c6d2942500ff465 Mon Sep 17 00:00:00 2001 From: Derek Bekoe Date: Tue, 24 Jan 2017 16:26:02 -0800 Subject: [PATCH 3/7] Revert "Add Python 3.6 to CI" This reverts commit 24b617a427e174aedb0acca6690bb163f51baf2c. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ee6caf7..b76b624 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,7 +54,6 @@ python: - 3.3 - 3.4 - 3.5 -- 3.6 - pypy - pypy3 install: From 3588ed63418fab0d02e14b542101a4bd8ce8ed8c Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 22 Mar 2017 17:05:34 +0000 Subject: [PATCH 4/7] support 3.6 --- .travis.yml | 5 +++++ tox.ini | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b76b624..a2a9b2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,10 +34,14 @@ matrix: python: 3.3 - env: TOX_SUFFIX="boto" python: 3.4 + - env: TOX_SUFFIX="boto" + python: 3.6 - env: TOX_SUFFIX="requests1" python: 3.4 - env: TOX_SUFFIX="requests1" python: 3.5 + - env: TOX_SUFFIX="requests1" + python: 3.6 - env: TOX_SUFFIX="aiohttp" python: 2.6 - env: TOX_SUFFIX="aiohttp" @@ -54,6 +58,7 @@ python: - 3.3 - 3.4 - 3.5 +- 3.6 - pypy - pypy3 install: diff --git a/tox.ini b/tox.ini index fa60b54..d649931 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = {py26,py27,py33,py34,pypy,pypy3}-{flakes,requests27,requests26,requests25,requests24,requests23,requests22,requests1,httplib2,urllib317,urllib319,urllib3110,tornado3,tornado4,boto,boto3,aiohttp} +envlist = {py26,py27,py33,py34,py35,py36,pypy,pypy3}-{flakes,requests27,requests26,requests25,requests24,requests23,requests22,requests1,httplib2,urllib317,urllib319,urllib3110,tornado3,tornado4,boto,boto3,aiohttp} [testenv:flakes] skipsdist = True From 73dbc6f8cba87cf4865161dae6a656ca0a259b63 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 3 Apr 2017 15:43:20 +0100 Subject: [PATCH 5/7] add missing _get_content_length static method also add _is_textIO --- vcr/stubs/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vcr/stubs/__init__.py b/vcr/stubs/__init__.py index c12e194..c7e39be 100644 --- a/vcr/stubs/__init__.py +++ b/vcr/stubs/__init__.py @@ -335,6 +335,11 @@ class VCRConnection(object): super(VCRConnection, self).__setattr__(name, value) +for k, v in HTTPConnection.__dict__.items(): + if isinstance(v, staticmethod): + setattr(VCRConnection, k, v) + + class VCRHTTPConnection(VCRConnection): '''A Mocked class for HTTP requests''' _baseclass = HTTPConnection From 1092bcd1a1d7cabf100732d64a3b45133fc609ea Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 4 Apr 2017 10:25:43 +0100 Subject: [PATCH 6/7] add requests 2.13 --- .travis.yml | 1 + tox.ini | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index a2a9b2b..c131581 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ env: - TOX_SUFFIX="requests25" - TOX_SUFFIX="requests26" - TOX_SUFFIX="requests27" + - TOX_SUFFIX="requests213" - TOX_SUFFIX="requests1" - TOX_SUFFIX="httplib2" - TOX_SUFFIX="boto" diff --git a/tox.ini b/tox.ini index d649931..27a2dd4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = {py26,py27,py33,py34,py35,py36,pypy,pypy3}-{flakes,requests27,requests26,requests25,requests24,requests23,requests22,requests1,httplib2,urllib317,urllib319,urllib3110,tornado3,tornado4,boto,boto3,aiohttp} +envlist = {py26,py27,py33,py34,py35,py36,pypy,pypy3}-{flakes,requests213,requests27,requests26,requests25,requests24,requests23,requests22,requests1,httplib2,urllib317,urllib319,urllib3110,tornado3,tornado4,boto,boto3,aiohttp} [testenv:flakes] skipsdist = True @@ -20,6 +20,7 @@ deps = pytest-httpbin PyYAML requests1: requests==1.2.3 + requests213: requests==2.13.0 requests27: requests==2.7.0 requests26: requests==2.6.0 requests25: requests==2.5.0 @@ -30,12 +31,12 @@ deps = urllib317: urllib3==1.7.1 urllib319: urllib3==1.9.1 urllib3110: urllib3==1.10.2 - {py26,py27,py33,py34,pypy}-tornado3: tornado>=3,<4 - {py26,py27,py33,py34,pypy}-tornado4: tornado>=4,<5 - {py26,py27,py33,py34,pypy}-tornado3: pytest-tornado - {py26,py27,py33,py34,pypy}-tornado4: pytest-tornado - {py26,py27,py33,py34}-tornado3: pycurl - {py26,py27,py33,py34}-tornado4: pycurl + {py26,py27,py33,py34,py35,py36,pypy}-tornado3: tornado>=3,<4 + {py26,py27,py33,py34,py35,py36,pypy}-tornado4: tornado>=4,<5 + {py26,py27,py33,py34,py35,py36,pypy}-tornado3: pytest-tornado + {py26,py27,py33,py34,py35,py36,pypy}-tornado4: pytest-tornado + {py26,py27,py33,py34,py35,py36}-tornado3: pycurl + {py26,py27,py33,py34,py35,py36}-tornado4: pycurl boto: boto boto3: boto3 aiohttp: aiohttp From dc2dc306d577678a7e6c027c6667cdc8671992a4 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 4 Apr 2017 10:31:44 +0100 Subject: [PATCH 7/7] pytest-httpbin doesn't support chunked requests on Python 3.6 --- tests/integration/test_requests.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/integration/test_requests.py b/tests/integration/test_requests.py index 804ab2e..4229a0f 100644 --- a/tests/integration/test_requests.py +++ b/tests/integration/test_requests.py @@ -4,8 +4,8 @@ import pytest import vcr from assertions import assert_cassette_empty, assert_is_json - requests = pytest.importorskip("requests") +from requests.exceptions import ConnectionError # noqa E402 def test_status_code(httpbin_both, tmpdir): @@ -100,11 +100,26 @@ def test_post(tmpdir, httpbin_both): assert req1 == req2 -def test_post_chunked_binary(tmpdir, httpbin_both): +def test_post_chunked_binary(tmpdir, httpbin): '''Ensure that we can send chunked binary without breaking while trying to concatenate bytes with str.''' data1 = iter([b'data', b'to', b'send']) data2 = iter([b'data', b'to', b'send']) - url = httpbin_both.url + '/post' + url = httpbin.url + '/post' + with vcr.use_cassette(str(tmpdir.join('requests.yaml'))): + req1 = requests.post(url, data1).content + + with vcr.use_cassette(str(tmpdir.join('requests.yaml'))): + req2 = requests.post(url, data2).content + + assert req1 == req2 + + +@pytest.mark.xfail('sys.version_info >= (3, 6)', strict=True, raises=ConnectionError) +def test_post_chunked_binary_secure(tmpdir, httpbin_secure): + '''Ensure that we can send chunked binary without breaking while trying to concatenate bytes with str.''' + data1 = iter([b'data', b'to', b'send']) + data2 = iter([b'data', b'to', b'send']) + url = httpbin_secure.url + '/post' with vcr.use_cassette(str(tmpdir.join('requests.yaml'))): req1 = requests.post(url, data1).content print(req1)