Skip to content

Commit

Permalink
Merge pull request #303 from graingert/support-3.6
Browse files Browse the repository at this point in the history
support 3.6
  • Loading branch information
graingert authored May 2, 2017
2 parents 0e421b5 + dc2dc30 commit 204cb8f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,10 +35,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"
Expand All @@ -54,6 +59,7 @@ python:
- 3.3
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
install:
Expand Down
21 changes: 18 additions & 3 deletions tests/integration/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
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):
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 8 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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,requests213,requests27,requests26,requests25,requests24,requests23,requests22,requests1,httplib2,urllib317,urllib319,urllib3110,tornado3,tornado4,boto,boto3,aiohttp}

[testenv:flakes]
skipsdist = True
Expand All @@ -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
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion vcr/stubs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _url(self, uri):
)
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,
Expand Down Expand Up @@ -335,6 +335,11 @@ def __setattr__(self, name, value):
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
Expand Down

0 comments on commit 204cb8f

Please sign in to comment.