Skip to content

Commit f08d8a8

Browse files
committed
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.
1 parent 212489d commit f08d8a8

File tree

1 file changed

+35
-33
lines changed

1 file changed

+35
-33
lines changed

tests/test_parser.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -330,69 +330,71 @@ def function():
330330
try:
331331
if something(4):
332332
break
333+
elif something(6):
334+
x = 7
333335
else:
334-
if something(7):
336+
if something(9):
335337
continue
336338
else:
337339
continue
338-
if also_this(11):
339-
return 12
340+
if also_this(13):
341+
return 14
340342
else:
341-
raise Exception(14)
343+
raise Exception(16)
342344
finally:
343-
this_thing(16)
344-
that_thing(17)
345+
this_thing(18)
346+
that_thing(19)
345347
""")
346348
if env.PYBEHAVIOR.finally_jumps_back:
347349
self.assertEqual(
348-
parser.missing_arc_description(16, 5),
349-
"line 16 didn't jump to line 5, because the break on line 5 wasn't executed"
350+
parser.missing_arc_description(18, 5),
351+
"line 18 didn't jump to line 5, because the break on line 5 wasn't executed"
350352
)
351353
self.assertEqual(
352-
parser.missing_arc_description(5, 17),
353-
"line 5 didn't jump to line 17, because the break on line 5 wasn't executed"
354+
parser.missing_arc_description(5, 19),
355+
"line 5 didn't jump to line 19, because the break on line 5 wasn't executed"
354356
)
355357
self.assertEqual(
356-
parser.missing_arc_description(16, 8),
357-
"line 16 didn't jump to line 8, because the continue on line 8 wasn't executed"
358+
parser.missing_arc_description(18, 10),
359+
"line 18 didn't jump to line 10, because the continue on line 10 wasn't executed"
358360
)
359361
self.assertEqual(
360-
parser.missing_arc_description(8, 2),
361-
"line 8 didn't jump to line 2, because the continue on line 8 wasn't executed"
362+
parser.missing_arc_description(10, 2),
363+
"line 10 didn't jump to line 2, because the continue on line 10 wasn't executed"
362364
)
363365
self.assertEqual(
364-
parser.missing_arc_description(16, 12),
365-
"line 16 didn't jump to line 12, because the return on line 12 wasn't executed"
366+
parser.missing_arc_description(18, 14),
367+
"line 18 didn't jump to line 14, because the return on line 14 wasn't executed"
366368
)
367369
self.assertEqual(
368-
parser.missing_arc_description(12, -1),
369-
"line 12 didn't return from function 'function', "
370-
"because the return on line 12 wasn't executed"
370+
parser.missing_arc_description(14, -1),
371+
"line 14 didn't return from function 'function', "
372+
"because the return on line 14 wasn't executed"
371373
)
372374
self.assertEqual(
373-
parser.missing_arc_description(16, -1),
374-
"line 16 didn't except from function 'function', "
375-
"because the raise on line 14 wasn't executed"
375+
parser.missing_arc_description(18, -1),
376+
"line 18 didn't except from function 'function', "
377+
"because the raise on line 16 wasn't executed"
376378
)
377379
else:
378380
self.assertEqual(
379-
parser.missing_arc_description(16, 17),
380-
"line 16 didn't jump to line 17, because the break on line 5 wasn't executed"
381+
parser.missing_arc_description(18, 19),
382+
"line 18 didn't jump to line 19, because the break on line 5 wasn't executed"
381383
)
382384
self.assertEqual(
383-
parser.missing_arc_description(16, 2),
384-
"line 16 didn't jump to line 2, "
385-
"because the continue on line 8 wasn't executed"
385+
parser.missing_arc_description(18, 2),
386+
"line 18 didn't jump to line 2, "
387+
"because the continue on line 10 wasn't executed"
386388
" or "
387-
"the continue on line 10 wasn't executed"
389+
"the continue on line 12 wasn't executed"
388390
)
389391
self.assertEqual(
390-
parser.missing_arc_description(16, -1),
391-
"line 16 didn't except from function 'function', "
392-
"because the raise on line 14 wasn't executed"
392+
parser.missing_arc_description(18, -1),
393+
"line 18 didn't except from function 'function', "
394+
"because the raise on line 16 wasn't executed"
393395
" or "
394-
"line 16 didn't return from function 'function', "
395-
"because the return on line 12 wasn't executed"
396+
"line 18 didn't return from function 'function', "
397+
"because the return on line 14 wasn't executed"
396398
)
397399

398400
def test_missing_arc_descriptions_bug460(self):

0 commit comments

Comments
 (0)