为什么pytest在使用pythonmtest运行时取消选择所有测试?

2024-10-17 06:21:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以通过执行(在Windows上)来运行测试

pytest .\tests\test_x.py

结果:

================================= test session starts ==================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: C:\Users\......
collected 9 items

tests\test_x.py .........                                                         [100%]

================================== 9 passed in 3.67s ===================================

但是,以下两个命令

pytest -m tests
pytest -m test

结果如下。为什么在可以作为脚本运行时取消选择所有测试

PS C:\Users\......> pytest -m test
================================= test session starts ==================================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: C:\Users\......
collected 9 items / 9 deselected

================================ 9 deselected in 3.78s =================================

Tags: inpytestpytestsessiontestsitemsusers