首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当使用python -m测试运行时,为什么pytest取消选择所有测试?

当使用python -m测试运行时,为什么pytest取消选择所有测试?
EN

Stack Overflow用户
提问于 2020-10-31 10:09:59
回答 1查看 1.1K关注 0票数 1

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

代码语言:javascript
复制
pytest .\tests\test_x.py

结果:

代码语言:javascript
复制
================================= 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 ===================================

但是,以下两个命令

代码语言:javascript
复制
pytest -m tests
pytest -m test

得到了以下结果。为什么所有的测试都被取消选择,而它们可以作为脚本运行?

代码语言:javascript
复制
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 =================================
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-31 10:26:22

您正在使用-m,它根据您标记测试的方式过滤要运行的测试。您告诉pytest只运行标记为@pytest.mark.test的测试。

想必,您没有任何这样标记的测试。

https://docs.pytest.org/en/stable/example/markers.html#mark-run

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64617770

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档