[Python-checkins] CVS: python/dist/src/Lib/test test_exceptions.py,1.9,1.10

Fred L. Drake python-dev@python.org
Fri, 8 Sep 2000 09:32:36 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory slayer.i.sourceforge.net:/tmp/cvs-serv17644

Modified Files:
	test_exceptions.py 
Log Message:

Add test cases to make sure we get the right SyntaxError message for
various illegal uses of "continue".


Index: test_exceptions.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_exceptions.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** test_exceptions.py	2000/09/01 06:53:51	1.9
--- test_exceptions.py	2000/09/08 16:32:33	1.10
***************
*** 87,90 ****
--- 87,139 ----
  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)