PyCharm, Django: zero code coverage PyCharm, Django: zero code coverage django django

PyCharm, Django: zero code coverage


If you access your project via any symlink in the path, coverage display will fail.

Try to open same project through real path, and you will get correct behavior.

https://youtrack.jetbrains.com/issue/PY-17616

PS: Refreshing old question, as bug still has not been fixed.


I had a similar issue using the PyCharm bundled coverage.py

The tests were running fine, but the coverage results were not loaded, "0%" or "not covered" everywhere.

There was an error logged in the PyCharm console though, following the output of the tests, that was coverage.py related:

/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python "/Applications/PyCharm 2.5 EAP.app/helpers/run_coverage.py" run "--omit=/Applications/PyCharm 2.5 EAP.app/helpers" bin/testCreating test database for alias 'default'...................................----------------------------------------------------------------------Ran xx tests in xxsOKNo source for code: '/path/file.py' (<- error)Process finished with exit code 0

My solution was to run the bundled coverage.py with the option to ignore errors: "-i".

I've edit the bundled "run_coverage.py" file, you can see its location in the console output, and add the "-i" option in the last line:

main(["xml", "-o", coverage_file + ".xml"])

to:

main(["xml", "-i", "-o", coverage_file + ".xml"])

This worked for me, the error is ignored and all the coverage data are now loaded in the UI.

If using "-i" solve the issue on your side, a better solution would be to fix the errors, but until then, you'll see coverage results.


I've also been trying to solve this issue in Ubuntu.

At the moment I tried with both the apt-get Python and the Enthought Canopy stack, with no success. In Windows however it does work (using Canopy).

I've used the following code:

# in a.pyclass A(object):    def p(self, a):        return a# in test_a.pyfrom unittest import TestCase, mainfrom a import Aclass TestA(TestCase):    def test_p(self):        inst = A()        val = inst.p("a")        self.assertEqual("a", val)if _name_ == "__main__":    main()