HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/test/__pycache__/test_symtable.cpython-36.pyc
3


 \'�@sFdZddlZddlZdZdd�ZGdd�dej�ZedkrBej�dS)	z&
Test the API of the symtable module.
�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
cCs&x |j�D]}|j�|kr
|Sq
WdS)N)�get_children�get_name)�block�nameZch�r�%/usr/lib64/python3.6/test_symtable.py�
find_block$src@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/�Zd0d1�Z d2S)3�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_type4s
zSymtableTest.test_typecCs4|j|jj��|j|jj��|j|jj��dS)N)�assertFalserZis_optimizedZhas_exec�
assertTruer)rrrr�test_optimized;szSymtableTest.test_optimizedcCsD|j|jj��|j|jj��|j|jj��|j|jj��dS)N)rrZ	is_nestedrrrr)rrrr�test_nestedAszSymtableTest.test_nestedcCs4|j|jj��|j|jj��|j|jj��dS)N)rrZhas_childrenrrr)rrrr�
test_childrenGszSymtableTest.test_childrencCs(|j|jj�d�|j|jj�d�dS)Nr�)rrZ
get_linenor)rrrr�test_linenoLszSymtableTest.test_linenocCst|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_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�lookup�	is_globalrZis_declared_globalrr)rrrr�test_globalsXszSymtableTest.test_globalscCs0|j|jjd�j��|j|jjd�j��dS)Nr")rrr(�is_localrr)rrrr�
test_local`szSymtableTest.test_localcCsF|j|jjd�j��|j|jjd�j��|j|jjd�j��dS)Nr"r)rrr(Z
is_referencedrr)rrrr�test_referenceddszSymtableTest.test_referencedcCs>x"dD]}|j|jj|�j��qW|j|jjd�j��dS)Nrr!r r")rr!r )rrr(Zis_parameterr)rZsymrrr�test_parametersis
zSymtableTest.test_parameterscCs6|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)Nrr
rrZnamespace_testr"�)
rrr(�is_namespacerrrZ
get_namespacerr/Zget_namespacesr0�
ValueError)rZns_testrrr�test_namespacestszSymtableTest.test_namespacescCsr|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�tjddd�}|j�d}|j|jd�j��|j|jd�j��|j|jd�j��tjddd�}|j�d}|j|jd�j��|j|jd�j��dS)Nzdef f():
    x: int
Ztestrrr"zdef f():
    x = 1
)�symtablerrr(r+Zis_annotatedrr))rZst1Zst2Zst3Zst4rrr�test_annotated�szSymtableTest.test_annotatedcCs|j|jjd�j��dS)N�sys)rrr(Zis_imported)rrrr�
test_imported�szSymtableTest.test_importedcCsR|j|jj�d�|j|jj�d�|j|jjd�j�d�|j|jj�d�dS)Nrrr"r)rrrrr(r)rrrr�	test_name�szSymtableTest.test_namecCs|j|jj�d�dS)Nr
)r
)rrZget_methods)rrrr�test_class_info�szSymtableTest.test_class_infoc s��fdd�}|dd�|dd�tjddd	��jt��.�jt��tjdtd�d	�WdQRXWdQRX�jt��tjdtd�d	�WdQRX�jt��tjdtd�d	�WdQRXdS)
Ncstytj|dd�WnLtk
r^}z0�j|jd��j|jd��j|j|�WYdd}~XnX�jd|f�dS)Nrr�zno SyntaxError for %r)r8�SyntaxErrorr�filename�lineno�offsetZfail)Z
brokencoderB�e)rrr�
checkfilename�s z9SymtableTest.test_filename_correct.<locals>.checkfilenamezdef f(x): foo)(�zdef f(x): global x�
�passsspamr)r8ZassertWarns�DeprecationWarningr0�	TypeError�	bytearray�
memoryview�list)rrDr)rr�test_filename_correct�s	

&z"SymtableTest.test_filename_correctcCstjddd�}dS)N�42r
�eval)r8)r�symbolsrrr�	test_eval�szSymtableTest.test_evalcCstjddd�}dS)NrNr
Zsingle)r8)rrPrrr�test_single�szSymtableTest.test_singlecCstjddd�}dS)Nzdef f(x): return xr
r)r8)rrPrrr�	test_exec�szSymtableTest.test_execN)!�__name__�
__module__�__qualname__r8�	TEST_CODErrrr
rrrrrrrrr'r*r,r-r.r2r6r7r9r;r<r=rMrQrRrSrrrrr	*s6





r	�__main__)	�__doc__r8ZunittestrWrZTestCaser	rT�mainrrrr�<module>s