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)

 

posted @ 2025-12-11 15:23  Joeyin  阅读(0)  评论(0)    收藏  举报