是否可以从coverage.py报告中排除测试目录? [英] Is it possible exclude test directories from coverage.py reports?

查看:181
本文介绍了是否可以从coverage.py报告中排除测试目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是具有python单元测试的菜鸟,尤其是coverage.py.是否希望覆盖报告包含您实际测试文件的覆盖范围?

I'm kind of a rookie with python unit testing, and particularly coverage.py. Is it desirable to have coverage reports include the coverage of your actual test files?

以下是我的 HTML报告的屏幕截图.

Here's a screenshot of my HTML report as an example.

您可以看到该报告包含tests/test_credit_card.起初,我试图从报告中省略tests/目录,像这样:

You can see that the report includes tests/test_credit_card. At first I was trying to omit the tests/ directory from the reports, like so:

coverage html --omit=tests/ -d tests/coverage

我尝试了该命令的几种变体,但是我无法终生 将测试/排除在外.接受失败后,我开始怀疑测试文件是否应该包含在报告中.

I tried several variations of that command but I could not for the life of me get the tests/ excluded. After accepting defeat, I began to wonder if maybe the test files are supposed to be included in the report.

有人能对此有所启发吗?

Can anyone shed some light on this?

推荐答案

coverage html --omit="*/test*" -d tests/coverage

这篇关于是否可以从coverage.py报告中排除测试目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆