Im generating a coverage report with nosetest using the following command:
nosetests --exe --with-coverage --cover-html --cover-package=Mypackage Tests/
In my tests Im using some classes and almost all classes are found except one thats called:
TestCasesFilter
After trying some thigns I found out that when I rename the class to something else eg OneTestCasesFilter the class is added to the coverage report. Our naming convention requires us to name the class after the table in the datbase that is written to so in this case TestCases. Is it possible to add the class to the coverage report without renaming the class?
Im using:
python 2.7.14
coverage 4.4.1
nose 1.3.7
My setup is a bit different than yours, but I was seeing a similar problem. I have a setup.cfg file in the root of my python package that looks like this:
[nosetests] with-coverage=1 cover-xml=1 cover-xml-file=coverage.xml cover-package=companyname
With this setup.cfg file, I was not seeing companyname/test_base.py show up in the coverage report that nosetests spits out at the end. I was, however, seeing it show up when I ran coverage report
so I know the data is being collected.
Looking at the documentation I saw a couple of potential options to fix. I was able to resolve the issue by adding cover-tests=1
to my setup.cfg file. The docs describe this option as
--cover-tests Include test modules in coverage report
It looks like whatever algorithm nose uses to determine what is a "test" isn't very smart and maybe only looks at class names
Since you're using the command-line to pass options, I think you need to add --cover-tests when you invoke nosetests
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.