1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 09:13:23 +00:00

pytest-httpbin doesn't support chunked requests on Python 3.6

This commit is contained in:
Thomas Grainger
2017-04-04 10:31:44 +01:00
parent 1092bcd1a1
commit dc2dc306d5

View File

@@ -4,8 +4,8 @@ import pytest
import vcr import vcr
from assertions import assert_cassette_empty, assert_is_json from assertions import assert_cassette_empty, assert_is_json
requests = pytest.importorskip("requests") requests = pytest.importorskip("requests")
from requests.exceptions import ConnectionError # noqa E402
def test_status_code(httpbin_both, tmpdir): def test_status_code(httpbin_both, tmpdir):
@@ -100,11 +100,26 @@ def test_post(tmpdir, httpbin_both):
assert req1 == req2 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.''' '''Ensure that we can send chunked binary without breaking while trying to concatenate bytes with str.'''
data1 = iter([b'data', b'to', b'send']) data1 = iter([b'data', b'to', b'send'])
data2 = 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'))): with vcr.use_cassette(str(tmpdir.join('requests.yaml'))):
req1 = requests.post(url, data1).content req1 = requests.post(url, data1).content
print(req1) print(req1)