summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-03-18 07:56:52 (GMT)
committerGitHub <noreply@github.com>2018-03-18 07:56:52 (GMT)
commitfe2bbb1869b42222a3f331a3dfb8b304a19a5819 (patch)
tree0f9e51eb7b9dbfab1d92a1538cef297081a46b55 /Lib/test/test_grammar.py
parent134cb01cda50f02725575808130b05d2d776693f (diff)
downloadcpython-fe2bbb1869b42222a3f331a3dfb8b304a19a5819.zip
cpython-fe2bbb1869b42222a3f331a3dfb8b304a19a5819.tar.gz
cpython-fe2bbb1869b42222a3f331a3dfb8b304a19a5819.tar.bz2
bpo-32489: Allow 'continue' in 'finally' clause. (GH-5822)
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index d89bfdc..ee41362 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -859,6 +859,59 @@ class GrammarTests(unittest.TestCase):
break
self.assertEqual(count, 0)
+ def test_continue_in_finally(self):
+ count = 0
+ while count < 2:
+ count += 1
+ try:
+ pass
+ finally:
+ continue
+ break
+ self.assertEqual(count, 2)
+
+ count = 0
+ while count < 2:
+ count += 1
+ try:
+ break
+ finally:
+ continue
+ self.assertEqual(count, 2)
+
+ count = 0
+ while count < 2:
+ count += 1
+ try:
+ 1/0
+ finally:
+ continue
+ break
+ self.assertEqual(count, 2)
+
+ for count in [0, 1]:
+ try:
+ pass
+ finally:
+ continue
+ break
+ self.assertEqual(count, 1)
+
+ for count in [0, 1]:
+ try:
+ break
+ finally:
+ continue
+ self.assertEqual(count, 1)
+
+ for count in [0, 1]:
+ try:
+ 1/0
+ finally:
+ continue
+ break
+ self.assertEqual(count, 1)
+
def test_return_in_finally(self):
def g1():
try: