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

Use built-in helpers to avoid use of async keywords which cause syntax errors on 2.x

This commit is contained in:
Steinn Eldjárn Sigurðarson
2019-06-28 13:30:14 +00:00
parent cc55ef5b35
commit 6c41b8b723

View File

@@ -93,20 +93,15 @@ def test_binary(tmpdir, scheme):
assert cassette.play_count == 1
@pytest.mark.asyncio
async def test_stream(tmpdir, scheme):
def test_stream(tmpdir, scheme):
url = scheme + '://httpbin.org/get'
headers = {'Content-Type': 'application/json'}
with vcr.use_cassette(str(tmpdir.join('stream.yaml'))):
async with aiohttp.ClientSession() as session:
resp = await session.get(url, headers=headers)
body = await resp.read() # do not use stream interface here, the stream seems exhausted by vcr
resp, body = get(url, output='raw') # XXX: headers?
with vcr.use_cassette(str(tmpdir.join('stream.yaml'))) as cassette:
async with aiohttp.ClientSession() as session:
cassette_resp = await session.get(url, headers=headers)
cassette_body = await cassette_resp.content.read()
cassette_resp, cassette_body = get(url, output='raw')
assert cassette_body == body
assert cassette.play_count == 1