Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的项目中有 2 个文件(a.py和b.py)。a.py文件被导入到单元测试文件 ( test_prog.py) 中,并且为它编写了测试。Pytest-cov 显示了这个文件的覆盖率。
a.py
b.py
test_prog.py
但是对于另一个文件b.py- 它在代码覆盖率输出中看不到。除非在其中一个单元测试中导入,否则 Pytest-cov 不考虑文件进行覆盖率分析?
我遇到了同样的问题。
快速搜索后,我发现您必须__init__在源文件夹中布置结构,以便能够在覆盖率报告中收集那些未被测试的文件。
__init__
有关文件的更多信息,请参阅此__init__内容。