You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally reported byGlen Nelson (Bitbucket: glen_nelson, GitHub: Unknown)
Sample code below was run with:
python 3.5.2
coverage 4.4.1
nose 1.3.7
Consider the following two files:
#!python
#foo.py
def foo(items):
for item in items:
v1 = 5 if item > 5 else None
v2 = item
if not v1 or not v2:
continue
print(v1)
print(v2)
#!python
#test_foo.py
from unittest import TestCase
from reproduce import foo
class TestFoo(TestCase):
def test_foo(self):
foo.foo([1, 2, 3, 4, 5, 6, 7])
We would expect full coverage of 'foo' here from the test. As we can see, when item is 1-5, we should hit the continue, else we should reach the prints.
Running coverage through nosetests was done with the following command
nosetests -P --with-coverage --cover-erase --cover-inclusive --cover-package reproduce --cover-html-dir=test_coverage_unit --cover-html tests/unit/reproduce
...
Name Stmts Miss Cover
-------------------------------------------------------------------
reproduce/foo.py 8 1 88%
The missing line is the 'continue', due to short-circuting.
We see on 47, we jump directly back to 7 (the for loop iterator) if v1 is false. If instead v2 is false, we fall through the jump to 60, hitting the continue (line 57), which brings us back to line 7. It looks the coverage is only counting it if we hit line 57.
Originally reported by Glen Nelson (Bitbucket: glen_nelson, GitHub: Unknown)
Sample code below was run with:
Consider the following two files:
We would expect full coverage of 'foo' here from the test. As we can see, when item is 1-5, we should hit the continue, else we should reach the prints.
Running coverage through nosetests was done with the following command
The missing line is the 'continue', due to short-circuting.
The text was updated successfully, but these errors were encountered: