mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
Use built-in helpers to avoid use of async keywords which cause syntax errors on 2.x
This commit is contained in:
@@ -93,20 +93,15 @@ def test_binary(tmpdir, scheme):
|
|||||||
assert cassette.play_count == 1
|
assert cassette.play_count == 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
def test_stream(tmpdir, scheme):
|
||||||
async def test_stream(tmpdir, scheme):
|
|
||||||
url = scheme + '://httpbin.org/get'
|
url = scheme + '://httpbin.org/get'
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
|
||||||
with vcr.use_cassette(str(tmpdir.join('stream.yaml'))):
|
with vcr.use_cassette(str(tmpdir.join('stream.yaml'))):
|
||||||
async with aiohttp.ClientSession() as session:
|
resp, body = get(url, output='raw') # XXX: headers?
|
||||||
resp = await session.get(url, headers=headers)
|
|
||||||
body = await resp.read() # do not use stream interface here, the stream seems exhausted by vcr
|
|
||||||
|
|
||||||
with vcr.use_cassette(str(tmpdir.join('stream.yaml'))) as cassette:
|
with vcr.use_cassette(str(tmpdir.join('stream.yaml'))) as cassette:
|
||||||
async with aiohttp.ClientSession() as session:
|
cassette_resp, cassette_body = get(url, output='raw')
|
||||||
cassette_resp = await session.get(url, headers=headers)
|
|
||||||
cassette_body = await cassette_resp.content.read()
|
|
||||||
assert cassette_body == body
|
assert cassette_body == body
|
||||||
assert cassette.play_count == 1
|
assert cassette.play_count == 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user