test_request.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:backend.ai-client-py 作者: lablup 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号