我有一个使用pytest的python项目。我们有一些异步函数,因此需要进行异步测试。从这个意义上说,我们将pytest-asyncio包添加为依赖项。现在,我们可以运行我们的测试,但是当我们尝试使用Visual Test Explorer对它们进行调试时,我们发现它不会在断点上停止。
我试着在谷歌上搜索一些旧的帖子,但是找不到任何问题。有没有人知道这是一个已知的问题,或者我如何解决这个问题?
基本上,要复制这个文件,您需要使用以下测试生成一个python文件:
import pytest
async def foo():
hello = "123"
print(hello)
return hello
@pytest.mark.asyncio
async def test_foo():
result = await foo()
assert "123" == result您首先需要运行pip install pytest asyncio pytest-asyncio,在print(hello)行上添加一些断点,然后使用VS运行测试。
提前感谢!
发布于 2022-03-22 05:51:05

你选择Debug Test而不是Run Test吗?
https://stackoverflow.com/questions/71563121
复制相似问题