0001 from test.test_support import vereq, TestFailed 0002 0003 import _symtable 0004 0005 symbols = _symtable.symtable("def f(x): return x", "?", "exec") 0006 0007 vereq(symbols[0].name, "global") 0008 vereq(len([ste for ste in symbols.values() if ste.name == "f"]), 1) 0009 0010 # Bug tickler: SyntaxError file name correct whether error raised 0011 # while parsing or building symbol table. 0012 def checkfilename(brokencode): 0013 try: 0014 _symtable.symtable(brokencode, "spam", "exec") 0015 except SyntaxError, e: 0016 vereq(e.filename, "spam") 0017 else: 0018 raise TestFailed("no SyntaxError for %r" % (brokencode,)) 0019 checkfilename("def f(x): foo)(") # parse-time 0020 checkfilename("def f(x): global x") # symtable-build-time 0021
Generated by PyXR 0.9.4