ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

pytest 测试 async for以及 async 方法

pytest 测试 async for以及 async 方法

参考:https://thenonfunctionaldev.com/tutorial-async-tdd-with-pytest-asyncio/

  https://pytest-with-eric.com/pytest-advanced/pytest-asyncio/

测试 async for resp in 方法

 1 from aiostream.stream import list as alist
 2 
 3 async def xx_method():
 4     async for resp in xx_method1():
 5         yield resp
 6 
 7 @pytest.mark.asyncio
 8 async def test_xx_method():
 9     data = await alist(xx_method())
10     print(data)

 

返回列表