def test_asend_with_appropriate_method(mocker, req_params):
req = Request(**req_params)
methods = Request._allowed_methods
for method in methods:
req.method = method
mock_reqfunc = mocker.patch.object(
aiohttp.ClientSession, method.lower(), autospec=True)
assert mock_reqfunc.call_count == 0
try:
# Ignore exceptions in `async with` statement. We're only
# interested in request call here.
await req.asend()
except BackendClientError:
pass
mock_reqfunc.assert_called_once_with(
mocker.ANY, req.build_url(), data=req._content, headers=req.headers)
评论列表
文章目录