home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / vyzkuste / firewally / firewally.exe / framework-2.3.exe / test_symtable.py < prev    next >
Text File  |  2003-12-30  |  680b  |  21 lines

  1. from test.test_support import vereq, TestFailed
  2.  
  3. import _symtable
  4.  
  5. symbols = _symtable.symtable("def f(x): return x", "?", "exec")
  6.  
  7. vereq(symbols[0].name, "global")
  8. vereq(len([ste for ste in symbols.values() if ste.name == "f"]), 1)
  9.  
  10. # Bug tickler: SyntaxError file name correct whether error raised
  11. # while parsing or building symbol table.
  12. def checkfilename(brokencode):
  13.     try:
  14.         _symtable.symtable(brokencode, "spam", "exec")
  15.     except SyntaxError, e:
  16.         vereq(e.filename, "spam")
  17.     else:
  18.         raise TestFailed("no SyntaxError for %r" % (brokencode,))
  19. checkfilename("def f(x): foo)(")  # parse-time
  20. checkfilename("def f(x): global x")  # symtable-build-time
  21.