diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_arcs.py | 30 | ||||
-rw-r--r-- | tests/test_parser.py | 10 |
2 files changed, 35 insertions, 5 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 826256b0..16efbcdf 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -1105,6 +1105,36 @@ class MiscArcTest(CoverageTest): arcz_missing="27", ) + def test_partial_generators(self): + # https://bitbucket.org/ned/coveragepy/issues/475/generator-expression-is-marked-as-not + # Line 2 is executed completely. + # Line 3 is started but not finished, because zip ends when #2 ends. + # Line 4 is never started. + cov = self.check_coverage("""\ + def f(a, b): + c = (i for i in a) # 2 + d = (j for j in b) # 3 + e = (k for k in b) # 4 + return dict(zip(c, d)) + + f(['a', 'b'], [1, 2]) + """, + arcz=".1 17 7. .2 23 34 45 5. -22 2-2 -33 3-3 -44 4-4", + arcz_missing="3-3 -44 4-4", + ) + # ugh, unexposed methods?? + filename = self.last_module_name + ".py" + fr = cov._get_file_reporter(filename) + arcs_executed = cov._analyze(filename).arcs_executed() + self.assertEqual( + fr.missing_arc_description(3, -3, arcs_executed), + "line 3 didn't finish the generator expression on line 3" + ) + self.assertEqual( + fr.missing_arc_description(4, -4, arcs_executed), + "line 4 didn't run the generator expression on line 4" + ) + class DecoratorArcTest(CoverageTest): """Tests of arcs with decorators.""" diff --git a/tests/test_parser.py b/tests/test_parser.py index 17f81ad8..ed18ccaa 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -256,19 +256,19 @@ class ParserMissingArcDescriptionTest(CoverageTest): """) self.assertEqual( parser.missing_arc_description(2, -2), - "line 2 didn't run the lambda on line 2" + "line 2 didn't finish the lambda on line 2" ) self.assertEqual( parser.missing_arc_description(3, -3), - "line 3 didn't run the generator expression on line 3" + "line 3 didn't finish the generator expression on line 3" ) self.assertEqual( parser.missing_arc_description(4, -4), - "line 4 didn't run the dictionary comprehension on line 4" + "line 4 didn't finish the dictionary comprehension on line 4" ) self.assertEqual( parser.missing_arc_description(5, -5), - "line 5 didn't run the set comprehension on line 5" + "line 5 didn't finish the set comprehension on line 5" ) def test_missing_arc_descriptions_for_exceptions(self): @@ -340,7 +340,7 @@ class ParserMissingArcDescriptionTest(CoverageTest): """) self.assertEqual( parser.missing_arc_description(2, -3), - "line 3 didn't run the lambda on line 3", + "line 3 didn't finish the lambda on line 3", ) |