Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_symtable.cpython-35.opt-2.pyc



���]��@s]ddlZddlZdZdd�ZGdd�dej�ZedkrYej�dS)�Na3
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�2/opt/alt/python35/lib64/python3.5/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�class�function)�assertEqual�topZget_typerrr
r)�selfrrr�	test_type4s
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_nestedrr
rr)rrrr�test_nestedAszSymtableTest.test_nestedcCsF|j|jj��|j|jj��|j|jj��dS)N)rrZhas_childrenrrr)rrrr�
test_childrenGszSymtableTest.test_childrencCs6|j|jj�d�|j|jj�d�dS)Nr�)rrZ
get_linenor
)rrrr�test_linenoLszSymtableTest.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")r
r�sortedZget_parametersZ
get_localsZget_globalsrZ	get_frees)r�funcZexpectedrrr�test_function_infoPs	("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_globalsXszSymtableTest.test_globalscCsB|j|jjd�j��|j|jjd�j��dS)Nr")rr
r(Zis_localrr)rrrr�
test_local`szSymtableTest.test_localcCsa|j|jjd�j��|j|jjd�j��|j|jjd�j��dS)Nr"r)rrr(Z
is_referencedr
r)rrrr�test_referenceddszSymtableTest.test_referencedcCsSx-dD]%}|j|jj|�j��qW|j|jjd�j��dS)Nrr!r r")rr!r )rr
r(Zis_parameterr)rZsymrrr�test_parametersis
#zSymtableTest.test_parameterscCsK|jt|jj��t|jj���|jt|jjd�dS)NZnot_here)r�lenrZget_identifiersZget_symbols�assertRaises�KeyErrorr()rrrr�test_symbol_lookupnszSymtableTest.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)Nrrr
rZnamespace_testr"�)
rrr(�is_namespacerr
rZ
get_namespacerr-Zget_namespacesr.�
ValueError)rZns_testrrr�test_namespacests(zSymtableTest.test_namespacescCs�|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|jjd�j��dS)Nr"r#r
r)rr
r(Zis_assignedrrrr)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)Nrr
r"r)rrrr
r(r)rrrr�	test_name�s"zSymtableTest.test_namecCs|j|jj�d�dS)Nr)r)rrZget_methods)rrrr�test_class_info�szSymtableTest.test_class_infocs��fdd�}|dd�|dd�tjddd	��jt��tjdtd�d	�WdQRXtjdtd�d	��jt��tjdtd�d	�WdQRXdS)
Ncs�ytj|dd�Wn^tk
rw}z>�j|jd��j|jd��j|j|�WYdd}~XnX�jd|f�dS)Nr
r
�zno SyntaxError for %r)�symtable�SyntaxErrorr�filename�lineno�offsetZfail)Z
brokencoder?�e)rrr�
checkfilename�s&z9SymtableTest.test_filename_correct.<locals>.checkfilenamezdef f(x): foo)(�zdef f(x): global x�
�passsspamr
)r;r.�	TypeError�	bytearray�
memoryview�list)rrAr)rr�test_filename_correct�s	

 z"SymtableTest.test_filename_correctcCstjddd�}dS)N�42r	�eval)r;)r�symbolsrrr�	test_eval�szSymtableTest.test_evalcCstjddd�}dS)NrJr	Zsingle)r;)rrLrrr�test_single�szSymtableTest.test_singlecCstjddd�}dS)Nzdef f(x): return xr	r
)r;)rrLrrr�	test_exec�szSymtableTest.test_execN) �__name__�
__module__�__qualname__r;�	TEST_CODErrrrr
rrrrrrrr'r)r*r+r,r0r4r5r7r8r9rIrMrNrOrrrrr*s4
r�__main__)r;ZunittestrSrZTestCaserrP�mainrrrr�<module>s�