![](/img/trans.png)
[英]When pytest run all tests in a directory, how can it decide which test to run last?
[英]Why pytest deselect all the tests when run with python -m test?
我可以通過執行(在 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 =================================
您正在使用-m
,它根據您標記測試的方式過濾要運行的測試。 你告訴 pytest 只運行標記為@pytest.mark.test
測試。
據推測,您沒有任何標記為此類的測試。
https://docs.pytest.org/en/stable/example/markers.html#mark-run
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.