我有一堆测试,我决定把它们放在一个类中,示例代码如下:
class IntegrationTests:
@pytest.mark.integrationtest
@pytest.mark.asyncio
async def test_job(self):
assert await do_stuff()
但是,当我尝试运行测试时:
pipenv run pytest -v -m integrationtest
,它们根本没有被检测到,在将它们移到类之前,我得到了以下信息:
我现在明白了:
2 passed, 4 deselected in 0.51 seconds
为什么pytest
没有检测到这些测试?不支持测试类吗?在
创建pytest.ini文件在
来自the docs:
示例:
在您的例子中,如果您不想更改类名
IntegrationTests
,请将python_classes
设置为*Tests
。在在类内运行测试
^{pr2}$EHA内部测试
类的名称需要以
Test
开头,pytest发现才能找到它。在见Conventions for Python test discovery
要运行类“TestIntegration”下的所有测试,可以使用:
相关问题 更多 >
编程相关推荐