home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2004 #2 / K-CD-2-2004.ISO / OpenOffice Sv / f_0397 / python-core-2.2.2 / lib / test / test_future.py < prev    next >
Encoding:
Python Source  |  2003-07-18  |  927 b   |  48 lines

  1. # Test various flavors of legal and illegal future statements
  2.  
  3. from test_support import unload
  4. import re
  5.  
  6. rx = re.compile('\((\S+).py, line (\d+)')
  7.  
  8. def check_error_location(msg):
  9.     mo = rx.search(msg)
  10.     print "SyntaxError %s %s" % mo.group(1, 2)
  11.  
  12. # The first two tests should work
  13.  
  14. unload('test_future1')
  15. import test_future1
  16.  
  17. unload('test_future2')
  18. import test_future2
  19.  
  20. unload('test_future3')
  21. import test_future3
  22.  
  23. # The remaining tests should fail
  24. try:
  25.     import badsyntax_future3
  26. except SyntaxError, msg:
  27.     check_error_location(str(msg))
  28.  
  29. try:
  30.     import badsyntax_future4
  31. except SyntaxError, msg:
  32.     check_error_location(str(msg))
  33.  
  34. try:
  35.     import badsyntax_future5
  36. except SyntaxError, msg:
  37.     check_error_location(str(msg))
  38.  
  39. try:
  40.     import badsyntax_future6
  41. except SyntaxError, msg:
  42.     check_error_location(str(msg))
  43.  
  44. try:
  45.     import badsyntax_future7
  46. except SyntaxError, msg:
  47.     check_error_location(str(msg))
  48.