Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_symtable.cpython-34.pyc

�
g fH�@sdZddlZddlZddlmZdZdd�ZGdd�dej�Zd	d
�Z	e
dkr{e	�ndS)z&
Test the API of the symtable module.
�N)�supporta3
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
cCs1x*|j�D]}|j�|kr
|Sq
WdS)N)Zget_children�get_name)�block�nameZch�r�7/opt/alt/python34/lib64/python3.4/test/test_symtable.py�
find_block%src@s`eZdZejedd�Zeed�Zeed�Zeed�Z	ee	d�Z
eed�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0S)1�SymtableTest�?�exec�Mine�a_method�spam�internal�foocCs�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�dS)N�module�classZfunction)�assertEqual�topZget_typerr
rr)�selfrrr�	test_type5s
zSymtableTest.test_typecCsF|j|jj��|j|jj��|j|jj��dS)N)�assertFalserZis_optimizedZhas_exec�
assertTruer)rrrr�test_optimized<szSymtableTest.test_optimizedcCs\|j|jj��|j|jj��|j|jj��|j|jj��dS)N)rrZ	is_nestedrrrr)rrrr�test_nestedBszSymtableTest.test_nestedcCsF|j|jj��|j|jj��|j|jj��dS)N)rrZhas_childrenrrr)rrrr�
test_childrenHszSymtableTest.test_childrencCs6|j|jj�d�|j|jj�d�dS)Nr�)rrZ
get_linenor)rrrr�test_linenoMszSymtableTest.test_linenocCs�|j}|jt|j��ddddg�ddddddg}|jt|j��|�|jt|j��ddg�|j|jj�d	�dS)
N�a�b�kw�varr�x�bar�glob)r")rr�sortedZget_parametersZ
get_localsZget_globalsrZ	get_frees)r�funcZexpectedrrr�test_function_infoQs	("zSymtableTest.test_function_infocCs�|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|jjd�j��dS)Nr$r#r"Zinstance_var)rr�lookupZ	is_globalrZis_declared_globalrr)rrrr�test_globalsYszSymtableTest.test_globalscCsB|j|jjd�j��|j|jjd�j��dS)Nr")rrr(Zis_localrr)rrrr�
test_localaszSymtableTest.test_localcCsa|j|jjd�j��|j|jjd�j��|j|jjd�j��dS)Nr"r)rrr(Z
is_referencedrr)rrrr�test_referencedeszSymtableTest.test_referencedcCsSx-dD]%}|j|jj|�j��qW|j|jjd�j��dS)Nrr!r r")rzvarzkw)rrr(Zis_parameterr)rZsymrrr�test_parametersjs
#zSymtableTest.test_parameterscCsK|jt|jj��t|jj���|jt|jjd�dS)NZnot_here)r�lenrZget_identifiersZget_symbols�assertRaises�KeyErrorr()rrrr�test_symbol_lookuposzSymtableTest.test_symbol_lookupcCs'|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�|jt|j�dS)Nrr
rrZnamespace_testr"�)
rrr(�is_namespacerrrZ
get_namespacerr-Zget_namespacesr.�
ValueError)rZns_testrrr�test_namespacesus(zSymtableTest.test_namespacescCs�|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|jjd�j��dS)Nr"r#rr
)rrr(Zis_assignedrrrr)rrrr�
test_assigned�s
zSymtableTest.test_assignedcCs#|j|jjd�j��dS)N�sys)rrr(Zis_imported)rrrr�
test_imported�szSymtableTest.test_importedcCsq|j|jj�d�|j|jj�d�|j|jjd�j�d�|j|jj�d�dS)Nrrr"r)rrrrr(r)rrrr�	test_name�s"zSymtableTest.test_namecCs|j|jj�d�dS)Nr
)za_method)rrZget_methods)rrrr�test_class_info�szSymtableTest.test_class_infocs*�fdd�}|d�|d�dS)Ncsjytj|dd�Wn8tk
rQ}z�j|jd�WYdd}~XnX�jd|f�dS)Nrrzno SyntaxError for %r)�symtable�SyntaxErrorr�filenameZfail)Z
brokencode�e)rrr�
checkfilename�s
&z9SymtableTest.test_filename_correct.<locals>.checkfilenamezdef f(x): foo)(zdef f(x): global xr)rr>r)rr�test_filename_correct�s
z"SymtableTest.test_filename_correctcCstjddd�}dS)N�42r
�eval)r:)r�symbolsrrr�	test_eval�szSymtableTest.test_evalcCstjddd�}dS)Nr@r
Zsingle)r:)rrBrrr�test_single�szSymtableTest.test_singlecCstjddd�}dS)Nzdef f(x): return xr
r)r:)rrBrrr�	test_exec�szSymtableTest.test_execN) �__name__�
__module__�__qualname__r:�	TEST_CODErrrr
rrrrrrrrr'r)r*r+r,r0r4r5r7r8r9r?rCrDrErrrrr	+s4

r	cCstjt�dS)N)rZrun_unittestr	rrrr�	test_main�srJ�__main__)�__doc__r:ZunittestZtestrrIrZTestCaser	rJrFrrrr�<module>s�