mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-10 09:35:34 +00:00
Add test to make sure we can post chunked binary data
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
'''Test requests' interaction with vcr'''
|
'''Test requests' interaction with vcr'''
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import vcr
|
import vcr
|
||||||
@@ -95,6 +96,21 @@ def test_post(tmpdir, scheme):
|
|||||||
assert req1 == req2
|
assert req1 == req2
|
||||||
|
|
||||||
|
|
||||||
|
def test_post_chunked_binary(tmpdir, scheme):
|
||||||
|
'''Ensure that we can send chunked binary without breaking while trying to concatenate bytes with string.'''
|
||||||
|
data1 = iter([b'data', b'to', b'send'])
|
||||||
|
data2 = iter([b'data', b'to', b'send'])
|
||||||
|
url = scheme + '://httpbin.org/post'
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('requests.yaml'))):
|
||||||
|
req1 = requests.post(url, data1).content
|
||||||
|
print(req1)
|
||||||
|
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('requests.yaml'))):
|
||||||
|
req2 = requests.post(url, data2).content
|
||||||
|
|
||||||
|
assert req1 == req2
|
||||||
|
|
||||||
|
|
||||||
def test_redirects(tmpdir, scheme):
|
def test_redirects(tmpdir, scheme):
|
||||||
'''Ensure that we can handle redirects'''
|
'''Ensure that we can handle redirects'''
|
||||||
url = scheme + '://httpbin.org/redirect-to?url=bytes/1024'
|
url = scheme + '://httpbin.org/redirect-to?url=bytes/1024'
|
||||||
|
|||||||
Reference in New Issue
Block a user