assert request.url == url
assert cassette_response_json == response_json
assert cassette.play_count == 1
+
+
+async def test_aiohttp_client_does_not_break_with_patching_request(aiohttp_client, tmpdir):
+ async def hello(request):
+ return aiohttp.web.Response(text='Hello, world')
+
+ app = aiohttp.web.Application()
+ app.router.add_get('/', hello)
+ client = await aiohttp_client(app)
+
+ with vcr.use_cassette(str(tmpdir.join('get.yaml'))):
+ await client.get('/')
def vcr_request(cassette, real_request):
@functools.wraps(real_request)
- @asyncio.coroutine
- def new_request(self, method, url, **kwargs):
+ async def new_request(self, method, url, **kwargs):
headers = kwargs.get('headers')
headers = self._prepare_headers(headers)
data = kwargs.get('data')
response.close()
return response
- response = yield from real_request(self, method, url, **kwargs) # NOQA: E999
+ response = await real_request(self, method, url, **kwargs) # NOQA: E999
vcr_response = {
'status': {
'message': response.reason,
},
'headers': dict(response.headers),
- 'body': {'string': (yield from response.read())}, # NOQA: E999
+ 'body': {'string': (await response.read())}, # NOQA: E999
'url': response.url,
}
cassette.append(vcr_request, vcr_response)