summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-01-09 07:01:35 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-01-10 09:46:18 -0500
commitf08d8a8a1d6f852a9bc04a950ec9f9facaf92f5e (patch)
tree6e29e59968983bf1916c11071b0591591681e7c8
parent212489d1c3fdc3445e8733bf8974339929e58df7 (diff)
downloadpython-coveragepy-git-f08d8a8a1d6f852a9bc04a950ec9f9facaf92f5e.tar.gz
Fix a test to be usable with PEP626
In the old code, the return and raise were unreachable, so Python 3.10 compiled them away. This meant the return and raise messages weren't in the missing arc fragments. The new code has a path to the return and raise.
-rw-r--r--tests/test_parser.py68
1 files changed, 35 insertions, 33 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 98308df9..9d3f9f67 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -330,69 +330,71 @@ class ParserMissingArcDescriptionTest(CoverageTest):
try:
if something(4):
break
+ elif something(6):
+ x = 7
else:
- if something(7):
+ if something(9):
continue
else:
continue
- if also_this(11):
- return 12
+ if also_this(13):
+ return 14
else:
- raise Exception(14)
+ raise Exception(16)
finally:
- this_thing(16)
- that_thing(17)
+ this_thing(18)
+ that_thing(19)
""")
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"
+ parser.missing_arc_description(18, 5),
+ "line 18 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"
+ parser.missing_arc_description(5, 19),
+ "line 5 didn't jump to line 19, 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"
+ parser.missing_arc_description(18, 10),
+ "line 18 didn't jump to line 10, because the continue on line 10 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"
+ parser.missing_arc_description(10, 2),
+ "line 10 didn't jump to line 2, because the continue on line 10 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"
+ parser.missing_arc_description(18, 14),
+ "line 18 didn't jump to line 14, because the return on line 14 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"
+ parser.missing_arc_description(14, -1),
+ "line 14 didn't return from function 'function', "
+ "because the return on line 14 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"
+ parser.missing_arc_description(18, -1),
+ "line 18 didn't except from function 'function', "
+ "because the raise on line 16 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"
+ parser.missing_arc_description(18, 19),
+ "line 18 didn't jump to line 19, 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"
+ parser.missing_arc_description(18, 2),
+ "line 18 didn't jump to line 2, "
+ "because the continue on line 10 wasn't executed"
" or "
- "the continue on line 10 wasn't executed"
+ "the continue 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"
+ parser.missing_arc_description(18, -1),
+ "line 18 didn't except from function 'function', "
+ "because the raise on line 16 wasn't executed"
" or "
- "line 16 didn't return from function 'function', "
- "because the return on line 12 wasn't executed"
+ "line 18 didn't return from function 'function', "
+ "because the return on line 14 wasn't executed"
)
def test_missing_arc_descriptions_bug460(self):