Skip to content

Commit 78e1116

Browse files
committed
test_grammar
1 parent ef2367c commit 78e1116

File tree

1 file changed

+45
-42
lines changed

1 file changed

+45
-42
lines changed

Lib/test/test_grammar.py

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -917,56 +917,59 @@ def g3():
917917
check_syntax_error(self, "class foo:return 1")
918918

919919
def test_break_in_finally(self):
920-
count = 0
921-
while count < 2:
922-
count += 1
923-
try:
924-
pass
925-
finally:
926-
break
927-
self.assertEqual(count, 1)
920+
with warnings.catch_warnings():
921+
warnings.simplefilter('ignore', SyntaxWarning)
928922

929-
count = 0
930-
while count < 2:
931-
count += 1
932-
try:
933-
continue
934-
finally:
935-
break
936-
self.assertEqual(count, 1)
923+
count = 0
924+
while count < 2:
925+
count += 1
926+
try:
927+
pass
928+
finally:
929+
break
930+
self.assertEqual(count, 1)
937931

938-
count = 0
939-
while count < 2:
940-
count += 1
941-
try:
942-
1/0
943-
finally:
944-
break
945-
self.assertEqual(count, 1)
932+
count = 0
933+
while count < 2:
934+
count += 1
935+
try:
936+
continue
937+
finally:
938+
break
939+
self.assertEqual(count, 1)
946940

947-
for count in [0, 1]:
941+
count = 0
942+
while count < 2:
943+
count += 1
944+
try:
945+
1/0
946+
finally:
947+
break
948+
self.assertEqual(count, 1)
949+
950+
for count in [0, 1]:
951+
self.assertEqual(count, 0)
952+
try:
953+
pass
954+
finally:
955+
break
948956
self.assertEqual(count, 0)
949-
try:
950-
pass
951-
finally:
952-
break
953-
self.assertEqual(count, 0)
954957

955-
for count in [0, 1]:
958+
for count in [0, 1]:
959+
self.assertEqual(count, 0)
960+
try:
961+
continue
962+
finally:
963+
break
956964
self.assertEqual(count, 0)
957-
try:
958-
continue
959-
finally:
960-
break
961-
self.assertEqual(count, 0)
962965

963-
for count in [0, 1]:
966+
for count in [0, 1]:
967+
self.assertEqual(count, 0)
968+
try:
969+
1/0
970+
finally:
971+
break
964972
self.assertEqual(count, 0)
965-
try:
966-
1/0
967-
finally:
968-
break
969-
self.assertEqual(count, 0)
970973

971974
def test_continue_in_finally(self):
972975
count = 0

0 commit comments

Comments
 (0)