def test_create_kernel_url():
mock_resp = asynctest.MagicMock(spec=aiohttp.ClientResponse)
mock_resp.status = 201
mock_resp.json = asynctest.MagicMock()
mock_req_obj = asynctest.MagicMock(spec=Request)
mock_req_obj.asend.return_value = mock_resp
with asynctest.patch('ai.backend.client.kernel.Request',
return_value=mock_req_obj) as mock_req_cls:
await Kernel.get_or_create('python')
mock_req_cls.assert_called_once_with(
'POST', '/kernel/create', mock.ANY)
mock_req_obj.asend.assert_called_once_with()
mock_req_obj.asend.return_value.json.assert_called_once_with()
test_asyncio_kernel.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录