summaryrefslogtreecommitdiff
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-10-05 10:39:28 -0400
committerNed Batchelder <ned@nedbatchelder.com>2018-10-06 10:25:29 -0400
commit04ff188349df84f73167108314e9698059830279 (patch)
tree679969c306537f5becab63ec9edc6a00a459098c /tests/test_parser.py
parentcf7e8717d73e638d92838f8534712351dda9e0f1 (diff)
downloadpython-coveragepy-git-04ff188349df84f73167108314e9698059830279.tar.gz
Finally jumps back to exiting lines
In Python 3.8, when a finally clause is run because a line in the try block is exiting the block, the exiting line is visited again after the finally block.
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py69
1 files changed, 50 insertions, 19 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index c2d70ee5..6340a44b 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -326,26 +326,57 @@ class ParserMissingArcDescriptionTest(CoverageTest):
this_thing(16)
that_thing(17)
""")
- self.assertEqual(
- parser.missing_arc_description(16, 17),
- "line 16 didn't jump to line 17, because the break on line 5 wasn't executed"
- )
- self.assertEqual(
- parser.missing_arc_description(16, 2),
- "line 16 didn't jump to line 2, "
- "because the continue on line 8 wasn't executed"
+ if env.PYBEHAVIOR.finally_jumps_back:
+ self.assertEqual(
+ parser.missing_arc_description(16, 5),
+ "line 16 didn't jump to line 5, because the break on line 5 wasn't executed"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(5, 17),
+ "line 5 didn't jump to line 17, because the break on line 5 wasn't executed"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(16, 8),
+ "line 16 didn't jump to line 8, because the continue on line 8 wasn't executed"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(8, 2),
+ "line 8 didn't jump to line 2, because the continue on line 8 wasn't executed"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(16, 12),
+ "line 16 didn't jump to line 12, because the return on line 12 wasn't executed"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(12, -1),
+ "line 12 didn't return from function 'function', "
+ "because the return on line 12 wasn't executed"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(16, -1),
+ "line 16 didn't except from function 'function', "
+ "because the raise on line 14 wasn't executed"
+ )
+ else:
+ self.assertEqual(
+ parser.missing_arc_description(16, 17),
+ "line 16 didn't jump to line 17, because the break on line 5 wasn't executed"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(16, 2),
+ "line 16 didn't jump to line 2, "
+ "because the continue on line 8 wasn't executed"
+ " or "
+ "the continue on line 10 wasn't executed"
+ )
+ self.assertEqual(
+ parser.missing_arc_description(16, -1),
+ "line 16 didn't except from function 'function', "
+ "because the raise on line 14 wasn't executed"
" or "
- "the continue on line 10 wasn't executed"
- )
- self.assertEqual(
- parser.missing_arc_description(16, -1),
- "line 16 didn't except from function 'function', "
- "because the raise on line 14 wasn't executed"
- " or "
- "line 16 didn't return from function 'function', "
- "because the return on line 12 wasn't executed"
- )
-
+ "line 16 didn't return from function 'function', "
+ "because the return on line 12 wasn't executed"
+ )
def test_missing_arc_descriptions_bug460(self):
parser = self.parse_text(u"""\
x = 1