[英]Pytest-cov does not consider a file for coverage analysis unless it is imported in one of the unit tests?
I have 2 files in my project ( a.py
and b.py
).我的项目中有 2 个文件(
a.py
和b.py
)。 a.py
file is imported in the unit test file ( test_prog.py
) and there are tests written for it. a.py
文件被导入到单元测试文件 ( test_prog.py
) 中,并且有为它编写的测试。 Pytest-cov shows the coverage for this file. Pytest-cov 显示了这个文件的覆盖率。
However for the other file b.py
- it is not seen in the code coverage output. Pytest-cov does not consider a file for coverage analysis unless it is imported in one of the unit tests?但是对于另一个文件
b.py
- 在代码覆盖率 output 中没有看到它。Pytest-cov 不考虑覆盖率分析的文件,除非它被导入到一个单元测试中?
I have encountered the same issue.我遇到了同样的问题。
After a quick search, I've found that you have to lay out __init__
structure in your source folder to be able to collect in the coverage report those files that are not being tested.快速搜索后,我发现您必须在源文件夹中布置
__init__
结构,以便能够在覆盖率报告中收集那些未被测试的文件。
See this for more about __init__
files.有关
__init__
文件的更多信息,请参阅 此内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.