我可以通过执行(在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 =================================发布于 2020-10-31 10:26:22
您正在使用-m,它根据您标记测试的方式过滤要运行的测试。您告诉pytest只运行标记为@pytest.mark.test的测试。
想必,您没有任何这样标记的测试。
https://docs.pytest.org/en/stable/example/markers.html#mark-run
https://stackoverflow.com/questions/64617770
复制相似问题