[Fixed]-Using coverage, how do I test this line?

12👍

The coverage report shows that the method is being called (line 80 is green). But it also shows that it was never defined (line 75 is red).

This is a classic problem of starting coverage too late. The simplest way to fix this is to use coverage to run your test runner, instead of using the test runner to run coverage:

$ coverage run -m nose --verbosity=1

UPDATED: to use with your original command:

$ coverage run manage.py test

but you’d want to uninstall the nose coverage plugin first.

Leave a comment