简体   繁体   中英

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 ). a.py file is imported in the unit test file ( test_prog.py ) and there are tests written for it. Pytest-cov shows the coverage for this file.

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?

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.

See this for more about __init__ files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM