Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you get unittest2 and coverage.py working together?

Tags:

How can you get unittest2 and coverage.py working together?

In theory something like

coverage run unit2 discover  

should work, but it currently just errors out.

If you are a nose user that will be the equivalent of nosetests --with-coverage.

like image 904
Jorge Vargas Avatar asked Jul 22 '10 19:07

Jorge Vargas


People also ask

How does Python code coverage work?

Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts of the code have been executed, then analyzes the source to identify code that could have been executed but was not. Coverage measurement is typically used to gauge the effectiveness of tests.

How do you increase code coverage in Python?

Increase coverage by adding more tests The code coverage has increased to 78% on adding another test case. It can be increased further to 100% in a similar fashion.


1 Answers

Try:

coverage run -m unittest discover 

works for me.

like image 161
jbastos Avatar answered Oct 11 '22 23:10

jbastos