summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-09-08 16:32:34 (GMT)
committerFred Drake <fdrake@acm.org>2000-09-08 16:32:34 (GMT)
commit72e48bd05fac4b5fd813f68a692a044a2a85f797 (patch)
tree5252d204d3cee2c201dc6e4c0bab43c64e940c4c /Lib/test/test_exceptions.py
parentfd1f1be98dfe66cd16d2e404e046ec462699dded (diff)
downloadcpython-72e48bd05fac4b5fd813f68a692a044a2a85f797.zip
cpython-72e48bd05fac4b5fd813f68a692a044a2a85f797.tar.gz
cpython-72e48bd05fac4b5fd813f68a692a044a2a85f797.tar.bz2
Add test cases to make sure we get the right SyntaxError message for
various illegal uses of "continue".
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r--Lib/test/test_exceptions.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 7ee203c..076f470 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -86,6 +86,55 @@ r(SyntaxError)
try: exec '/\n'
except SyntaxError: pass
+# make sure the right exception message is raised for each of these
+# code fragments:
+
+def ckmsg(src, msg):
+ try:
+ compile(src, '<fragment>', 'exec')
+ except SyntaxError, e:
+ print e.msg
+ if e.msg == msg:
+ print "ok"
+ else:
+ print "expected:", msg
+ else:
+ print "failed to get expected SyntaxError"
+
+s = '''\
+while 1:
+ try:
+ continue
+ except:
+ pass
+'''
+ckmsg(s, "'continue' not supported inside 'try' clause")
+s = '''\
+while 1:
+ try:
+ continue
+ finally:
+ pass
+'''
+ckmsg(s, "'continue' not supported inside 'try' clause")
+s = '''\
+while 1:
+ try:
+ if 1:
+ continue
+ finally:
+ pass
+'''
+ckmsg(s, "'continue' not supported inside 'try' clause")
+s = '''\
+try:
+ continue
+except:
+ pass
+'''
+ckmsg(s, "'continue' not properly in loop")
+ckmsg("continue\n", "'continue' not properly in loop")
+
r(IndentationError)
r(TabError)