;
Μβ"Ic               @   sx   d  Z  d d l Z d d l Z d d l m Z d Z d   Z Gd   d e j  Z d   Z	 e
 d	 k o e	   n d S(
   u&   
Test the API of the symtable module.
i    N(   u   supportu3  
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():
    pass

def namespace_test(): pass
def namespace_test(): pass
c             C   s3   x, |  j    D] } | j   | k o | Sq Wd  S(   N(   u   get_childrenu   get_name(   u   blocku   nameu   ch(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu
   find_block%   s     c             B   s"  |  Ee  Z e j e d  d  Z e e d  Z e e d  Z e e d  Z e e d  Z	 e e d  Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d S(   u   ?u   execu   Mineu   a_methodu   spamu   internalu   fooc             C   s   |  j  |  j j   d  |  j  |  j j   d  |  j  |  j j   d  |  j  |  j j   d  |  j  |  j j   d  d  S(   Nu   moduleu   classu   function(   u   assertEqualu   topu   get_typeu   Mineu   a_methodu   spamu   internal(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu	   test_type5   s
    c             C   sF   |  j  |  j j    |  j  |  j j    |  j |  j j    d  S(   N(   u   assertFalseu   topu   is_optimizedu   has_execu
   assertTrueu   spam(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_optimized<   s    c             C   s\   |  j  |  j j    |  j  |  j j    |  j  |  j j    |  j |  j j    d  S(   N(   u   assertFalseu   topu	   is_nestedu   Mineu   spamu
   assertTrueu   internal(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_nestedB   s    c             C   sF   |  j  |  j j    |  j  |  j j    |  j |  j j    d  S(   N(   u
   assertTrueu   topu   has_childrenu   Mineu   assertFalseu   foo(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_childrenH   s    c             C   s6   |  j  |  j j   d  |  j  |  j j   d  d  S(   Ni    i   (   u   assertEqualu   topu
   get_linenou   spam(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_linenoM   s    c          
   C   sh   |  j  } |  j | j   d	  |  j | j   d
  |  j | j   d  |  j |  j j   d  d  S(   Nu   au   bu   kwu   varu   baru   globu   internalu   x(   u   au   bu   kwu   var(   u   au   bu   baru   globu   internalu   kwu   varu   x(   u   baru   glob(   u   x(   u   spamu   assertEqualu   get_parametersu
   get_localsu   get_globalsu   internalu	   get_frees(   u   selfu   func(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_function_infoQ   s    	c             C   s   |  j  |  j j d  j    |  j  |  j j d  j    |  j |  j j d  j    |  j |  j j d  j    d  S(   Nu   globu   baru   xu   instance_var(   u
   assertTrueu   spamu   lookupu	   is_globalu   assertFalseu   internalu   Mine(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_globalsY   s    c             C   sB   |  j  |  j j d  j    |  j |  j j d  j    d  S(   Nu   x(   u
   assertTrueu   spamu   lookupu   is_localu   assertFalseu   internal(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu
   test_local_   s    c             C   sa   |  j  |  j j d  j    |  j  |  j j d  j    |  j |  j j d  j    d  S(   Nu   xu   internal(   u
   assertTrueu   internalu   lookupu   is_referencedu   spamu   assertFalse(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_referencedc   s    c             C   sS   x- d D]% } |  j  |  j j |  j    q W|  j |  j j d  j    d  S(   Nu   au   varu   kwu   x(   u   au   varu   kw(   u
   assertTrueu   spamu   lookupu   is_parameteru   assertFalse(   u   selfu   sym(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_parametersh   s     #c             C   sK   |  j  t |  j j    t |  j j     |  j t |  j j d  d  S(   Nu   not_here(   u   assertEqualu   lenu   topu   get_identifiersu   get_symbolsu   assertRaisesu   KeyErroru   lookup(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_symbol_lookupm   s    c             C   s'  |  j  |  j j d  j    |  j  |  j j d  j    |  j  |  j j d  j    |  j  |  j j d  j    |  j  |  j j d  j    |  j |  j j d  j    |  j |  j j d  j   |  j k  |  j j d  } |  j	 t
 | j    d  |  j t | j  d  S(   Nu   Mineu   a_methodu   spamu   internalu   namespace_testu   xi   (   u
   assertTrueu   topu   lookupu   is_namespaceu   Mineu   spamu   assertFalseu   assert_u   get_namespaceu   assertEqualu   lenu   get_namespacesu   assertRaisesu
   ValueError(   u   selfu   ns_test(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_namespacess   s    (c             C   s   |  j  |  j j d  j    |  j  |  j j d  j    |  j  |  j j d  j    |  j  |  j j d  j    |  j |  j j d  j    d  S(   Nu   xu   baru   spamu   a_method(   u
   assertTrueu   spamu   lookupu   is_assignedu   topu   Mineu   assertFalseu   internal(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_assigned   s
    c             C   s#   |  j  |  j j d  j    d  S(   Nu   sys(   u
   assertTrueu   topu   lookupu   is_imported(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_imported   s    c             C   sq   |  j  |  j j   d  |  j  |  j j   d  |  j  |  j j d  j   d  |  j  |  j j   d  d  S(   Nu   topu   spamu   xu   Mine(   u   assertEqualu   topu   get_nameu   spamu   lookupu   Mine(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu	   test_name   s    "c             C   s   |  j  |  j j   d  d  S(   Nu   a_method(   u   a_method(   u   assertEqualu   Mineu   get_methods(   u   self(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_class_info   s    c                s'     f d   } | d  | d  d  S(   Nc                sl   y t  j  |  d d  Wn: t k
 o. } z   j | j d  WYd  d  } ~ Xn X  j d |  f  d  S(   Nu   spamu   execu   no SyntaxError for %r(   u   symtableu   SyntaxErroru   assertEqualu   filenameu   fail(   u
   brokencodeu   e(   u   self(    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   checkfilename   s
    'u   def f(x): foo)(u   def f(x): global x(    (   u   selfu   checkfilename(    (   u   selfu/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_filename_correct   s    
c             C   s   t  j  d d d  } d  S(   Nu   42u   ?u   eval(   u   symtable(   u   selfu   symbols(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu	   test_eval    s    c             C   s   t  j  d d d  } d  S(   Nu   42u   ?u   single(   u   symtable(   u   selfu   symbols(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   test_single£   s    c             C   s   t  j  d d d  } d  S(   Nu   def f(x): return xu   ?u   exec(   u   symtable(   u   selfu   symbols(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu	   test_exec¦   s    N(   u   __name__u
   __module__u   symtableu	   TEST_CODEu   topu
   find_blocku   Mineu   a_methodu   spamu   internalu   foou	   test_typeu   test_optimizedu   test_nestedu   test_childrenu   test_linenou   test_function_infou   test_globalsu
   test_localu   test_referencedu   test_parametersu   test_symbol_lookupu   test_namespacesu   test_assignedu   test_importedu	   test_nameu   test_class_infou   test_filename_correctu	   test_evalu   test_singleu	   test_exec(   u
   __locals__(    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   SymtableTest+   s4   
																			u   SymtableTestc               C   s   t  j t  d  S(   N(   u   supportu   run_unittestu   SymtableTest(    (    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu	   test_mainͺ   s    u   __main__(   u   __doc__u   symtableu   unittestu   testu   supportu	   TEST_CODEu
   find_blocku   TestCaseu   SymtableTestu	   test_mainu   __name__(    (    (    u/   /mit/python/lib/python3.0/test/test_symtable.pyu   <module>   s   		