pytest-cov 一次涵盖许多应用程序

Ill*_*tov 3 django coverage.py pytest pytest-django

我构建了包含许多应用程序的 django 项目。现在我想为这些应用程序生成覆盖率报告。出于测试目的,我使用 py.test、pytest-django 和 pytest-cov。到目前为止,我只能通过在命令行上手动输入所有应用程序名称来生成报告:

py.test --cov-report html --cov=app1 --cov=app2 --cov=app3 --cov=app4 */tests.py
Run Code Online (Sandbox Code Playgroud)

pytest-cov 是否有办法用一个简单的表达式指定所有应用程序?

The*_*ler 5

假设您使用的是 bash,您可以使用它来扩展参数:

py.test --cov-report html --cov=app{1,2,3,4} */tests.py
Run Code Online (Sandbox Code Playgroud)

您还可以添加这些参数,pytest.ini以便在每次调用时自动传递它们。