why is python coverage saying lines were missed?
Asked Answered
H

1

6

I'm trying to use coverage with Django, but I seem to be getting incorrect results. My app is named "stats" and I have this test:

class ListSchoolsTest(TestCase):
    def test_initial_list(self):
        self.client.login(username='skeezy', password='skeezy')
        resp = self.client.get("/stats/list_schools/")
        self.assertEqual(resp.status_code, 200)

On the command line, I run:

coverage run --source="." manage.py test stats

And the test passes. All my views are currently in stats/views.py

But when I run "coverage report", I get this line:

Name                 Stmts   Miss  Cover
----------------------------------------
<snip>
stats/views            110    110     0%

Any idea what I am (not) doing that would cause coverage to report all lines missed in stats/views.py, even though it would have to be hit in order for the test to pass? (just as a belt-and-suspenders, I put a print statement in my view, and it's definitely getting hit.)

Hodges answered 2/9, 2013 at 2:31 Comment(1)
I'm having the same problem. In Windows the coverage works correctly, but when I send to Travis all statements not in the test itself are missed.Salic
C
-1

Maybe you have pip installed your app without the -e flag? Then the modules are not imported from your project directory but the path they were installed to and coverage thinks those are different files.

Christinchristina answered 3/4, 2014 at 22:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.