python - 为什么 pytest 在使用 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
推荐阅读
- javascript - 用 JavaScript 显示隐藏列表
- caching - 页面缓存和磁盘缓存有区别吗?
- java - 编写具有 3 个子类和测试器的约会超类。一切都可以编译,但用户输入后程序没有响应
- jenkins - 从 Jenkins 脚本化管道中搜索 LDAP
- lets-encrypt - certbot 无法验证域和连接被拒绝
- ajax - Google Analytics 自动跟踪 Ajax 在 jsf 应用程序中不起作用
- system-verilog - UVM DPI-C 功能导入
- c# - 串行端口基流提供部分/加扰/重复数据
- powershell - 如何在 FoxPro 应用程序启动中验证和禁用 SMB oplocks 和缓存
- java - 为什么 MySQL 没有连接到我在 Android Studio 中的应用程序?