随笔 - 42  文章 - 0 评论 - 0 阅读 - 8960
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

安装

pip install pytest

 

终端运行

  1. pytest:在当前目录中查找并运行所有符合测试用例命名规范的测试用例。

  2. pytest -q:以简化模式运行所有测试用例。

  3. pytest -v:以详细模式运行所有测试用例。

  4. pytest test_sample.py:运行指定的测试文件test_sample.py中的所有测试用例。

  5. pytest tests/:运行指定目录tests/下所有测试用例。

  6. pytest -m "mark":运行被标记为"mark"的测试用例。

  7. pytest --cov:使用覆盖率工具pytest-cov生成测试覆盖率报告。

  8. pytest --cov-report=html:以HTML格式生成测试覆盖率报告。

  9. pytest --fixtures:列出所有可用的fixtures(夹具)。

  10. pytest --fixtures-per-test:列出在每个测试用例中使用的夹具。

  11. pytest --last-failed 运行上次失败用例
posted on   会锻炼的猪  阅读(53)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
点击右上角即可分享
微信分享提示