ó {G_Tc@sydZddlZddlZddlmZdZd„Zdejfd„ƒYZd„Z e d krue ƒndS( s& Test the API of the symtable module. iÿÿÿÿN(t test_supportsM import sys glob = 42 class Mine: instance_var = 24 def a_method(p1, p2): pass def spam(a, b, *var, **kw): global bar bar = 47 x = 23 glob def internal(): return x return internal def foo(): exec 'm' from sys import * def namespace_test(): pass def namespace_test(): pass cCs1x*|jƒD]}|jƒ|kr |Sq WdS(N(t get_childrentget_name(tblocktnametch((s./usr/local/lib/python2.7/test/test_symtable.pyt find_block&st SymtableTestcBs8eZejdefƒejeddƒZWdQXeedƒZ ee dƒZ eedƒZ ee dƒZ eedƒZ d „Zd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!RS(s&import \* only allowed at module levelt?texecNtMineta_methodtspamtinternaltfoocCs|j|jjƒdƒ|j|jjƒdƒ|j|jjƒdƒ|j|jjƒdƒ|j|jjƒdƒdS(Ntmoduletclasstfunction(t assertEqualttoptget_typeR R R R (tself((s./usr/local/lib/python2.7/test/test_symtable.pyt test_type8s cCsž|j|jjƒƒ|j|jjƒƒ|j|jjƒƒ|j|jjƒƒ|j|jjƒƒ|j|jjƒƒ|j|jjƒƒdS(N(t assertFalseRt is_optimizedthas_execthas_import_start assertTrueR R(R((s./usr/local/lib/python2.7/test/test_symtable.pyttest_optimized?scCs\|j|jjƒƒ|j|jjƒƒ|j|jjƒƒ|j|jjƒƒdS(N(RRt is_nestedR R RR (R((s./usr/local/lib/python2.7/test/test_symtable.pyt test_nestedJscCsF|j|jjƒƒ|j|jjƒƒ|j|jjƒƒdS(N(RRt has_childrenR RR(R((s./usr/local/lib/python2.7/test/test_symtable.pyt test_childrenPscCs6|j|jjƒdƒ|j|jjƒdƒdS(Nii (RRt get_linenoR (R((s./usr/local/lib/python2.7/test/test_symtable.pyt test_linenoUscCs¤|j}|jt|jƒƒddddgƒddddddg}|jt|jƒƒ|ƒ|jt|jƒƒddgƒ|j|jjƒd ƒdS( NtatbtkwtvarR txtbartglob(R'(R Rtsortedtget_parameterst get_localst get_globalsR t get_frees(Rtfunctexpected((s./usr/local/lib/python2.7/test/test_symtable.pyttest_function_infoYs  ("cCs¾|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒdS(NR)R(R't instance_var(RR tlookupt is_globalRtis_declared_globalR R (R((s./usr/local/lib/python2.7/test/test_symtable.pyt test_globalsas cCsB|j|jjdƒjƒƒ|j|jjdƒjƒƒdS(NR'(RR R3tis_localRR (R((s./usr/local/lib/python2.7/test/test_symtable.pyt test_localiscCsa|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒdS(NR'R (RR R3t is_referencedR R(R((s./usr/local/lib/python2.7/test/test_symtable.pyttest_referencedmscCsSx-dD]%}|j|jj|ƒjƒƒqW|j|jjdƒjƒƒdS(NR#R&R%R'(R#svarskw(RR R3t is_parameterR(Rtsym((s./usr/local/lib/python2.7/test/test_symtable.pyttest_parametersrs #cCsK|jt|jjƒƒt|jjƒƒƒ|jt|jjdƒdS(Ntnot_here(RtlenRtget_identifierst get_symbolst assertRaisestKeyErrorR3(R((s./usr/local/lib/python2.7/test/test_symtable.pyttest_symbol_lookupwscCs'|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒ|jkƒ|jjdƒ}|jt |j ƒƒdƒ|j t |jƒdS(NR R R R tnamespace_testR'i( RRR3t is_namespaceR R Rt get_namespaceRR?tget_namespacesRBt ValueError(Rtns_test((s./usr/local/lib/python2.7/test/test_symtable.pyttest_namespaces}s(cCsŸ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒ|j|jjdƒjƒƒdS(NR'R(R R (RR R3t is_assignedRR RR (R((s./usr/local/lib/python2.7/test/test_symtable.pyt test_assignedŠs cCs#|j|jjdƒjƒƒdS(Ntsys(RRR3t is_imported(R((s./usr/local/lib/python2.7/test/test_symtable.pyt test_imported‘scCsq|j|jjƒdƒ|j|jjƒdƒ|j|jjdƒjƒdƒ|j|jjƒdƒdS(NRR R'R (RRRR R3R (R((s./usr/local/lib/python2.7/test/test_symtable.pyt test_name”s"cCs|j|jjƒdƒdS(NR (sa_method(RR t get_methods(R((s./usr/local/lib/python2.7/test/test_symtable.pyttest_class_infošscs'‡fd†}|dƒ|dƒdS(NcsXytj|ddƒWn&tk r?}ˆj|jdƒnXˆjd|fƒdS(NR R sno SyntaxError for %r(tsymtablet SyntaxErrorRtfilenametfail(t brokencodete(R(s./usr/local/lib/python2.7/test/test_symtable.pyt checkfilename s sdef f(x): foo)(sdef f(x): global x((RRZ((Rs./usr/local/lib/python2.7/test/test_symtable.pyttest_filename_corrects cCstjdddƒ}dS(Nt42Rteval(RT(Rtsymbols((s./usr/local/lib/python2.7/test/test_symtable.pyt test_evalªscCstjdddƒ}dS(NR\Rtsingle(RT(RR^((s./usr/local/lib/python2.7/test/test_symtable.pyt test_single­scCstjdddƒ}dS(Nsdef f(x): return xRR (RT(RR^((s./usr/local/lib/python2.7/test/test_symtable.pyt test_exec°s("t__name__t __module__Rtcheck_warningst SyntaxWarningRTt TEST_CODERRR R R R RRRRR R"R1R6R8R:R=RDRKRMRPRQRSR[R_RaRb(((s./usr/local/lib/python2.7/test/test_symtable.pyR,s8                cCstjtƒdS(N(Rt run_unittestR(((s./usr/local/lib/python2.7/test/test_symtable.pyt test_main´st__main__( t__doc__RTtunittestttestRRgRtTestCaseRRiRc(((s./usr/local/lib/python2.7/test/test_symtable.pyts   ˆ