Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_symtable.cpython-312.pyc

�

'Μg<F���dZddlZddlZddlZdZdZd�ZGd�dej�Ze	dk(rej�yy)	z&
Test the API of the symtable module.
�Na�
import sys

glob = 42
some_var = 12
some_non_assigned_global_var: int
some_assigned_global_var = 11

class Mine:
    instance_var = 24
    def a_method(p1, p2):
        pass

def spam(a, b, *var, **kw):
    global bar
    global some_assigned_global_var
    some_assigned_global_var = 12
    bar = 47
    some_var = 10
    x = 23
    glob
    def internal():
        return x
    def other_internal():
        nonlocal some_var
        some_var = 3
        return some_var
    return internal

def foo():
    pass

def namespace_test(): pass
def namespace_test(): pass

type Alias = int
type GenericAlias[T] = list[T]

def generic_spam[T](a):
    pass

class GenericMine[T: int]:
    pass
aS
# The following symbols are defined in ComplexClass
# without being introduced by a 'global' statement.
glob_unassigned_meth: Any
glob_unassigned_meth_pep_695: Any

glob_unassigned_async_meth: Any
glob_unassigned_async_meth_pep_695: Any

def glob_assigned_meth(): pass
def glob_assigned_meth_pep_695[T](): pass

async def glob_assigned_async_meth(): pass
async def glob_assigned_async_meth_pep_695[T](): pass

# The following symbols are defined in ComplexClass after
# being introduced by a 'global' statement (and therefore
# are not considered as local symbols of ComplexClass).
glob_unassigned_meth_ignore: Any
glob_unassigned_meth_pep_695_ignore: Any

glob_unassigned_async_meth_ignore: Any
glob_unassigned_async_meth_pep_695_ignore: Any

def glob_assigned_meth_ignore(): pass
def glob_assigned_meth_pep_695_ignore[T](): pass

async def glob_assigned_async_meth_ignore(): pass
async def glob_assigned_async_meth_pep_695_ignore[T](): pass

class ComplexClass:
    a_var = 1234
    a_genexpr = (x for x in [])
    a_lambda = lambda x: x

    type a_type_alias = int
    type a_type_alias_pep_695[T] = list[T]

    class a_class: pass
    class a_class_pep_695[T]: pass

    def a_method(self): pass
    def a_method_pep_695[T](self): pass

    async def an_async_method(self): pass
    async def an_async_method_pep_695[T](self): pass

    @classmethod
    def a_classmethod(cls): pass
    @classmethod
    def a_classmethod_pep_695[T](self): pass

    @classmethod
    async def an_async_classmethod(cls): pass
    @classmethod
    async def an_async_classmethod_pep_695[T](self): pass

    @staticmethod
    def a_staticmethod(): pass
    @staticmethod
    def a_staticmethod_pep_695[T](self): pass

    @staticmethod
    async def an_async_staticmethod(): pass
    @staticmethod
    async def an_async_staticmethod_pep_695[T](self): pass

    # These ones will be considered as methods because of the 'def' although
    # they are *not* valid methods at runtime since they are not decorated
    # with @staticmethod.
    def a_fakemethod(): pass
    def a_fakemethod_pep_695[T](): pass

    async def an_async_fakemethod(): pass
    async def an_async_fakemethod_pep_695[T](): pass

    # Check that those are still considered as methods
    # since they are not using the 'global' keyword.
    def glob_unassigned_meth(): pass
    def glob_unassigned_meth_pep_695[T](): pass

    async def glob_unassigned_async_meth(): pass
    async def glob_unassigned_async_meth_pep_695[T](): pass

    def glob_assigned_meth(): pass
    def glob_assigned_meth_pep_695[T](): pass

    async def glob_assigned_async_meth(): pass
    async def glob_assigned_async_meth_pep_695[T](): pass

    # The following are not picked as local symbols because they are not
    # visible by the class at runtime (this is equivalent to having the
    # definitions outside of the class).
    global glob_unassigned_meth_ignore
    def glob_unassigned_meth_ignore(): pass
    global glob_unassigned_meth_pep_695_ignore
    def glob_unassigned_meth_pep_695_ignore[T](): pass

    global glob_unassigned_async_meth_ignore
    async def glob_unassigned_async_meth_ignore(): pass
    global glob_unassigned_async_meth_pep_695_ignore
    async def glob_unassigned_async_meth_pep_695_ignore[T](): pass

    global glob_assigned_meth_ignore
    def glob_assigned_meth_ignore(): pass
    global glob_assigned_meth_pep_695_ignore
    def glob_assigned_meth_pep_695_ignore[T](): pass

    global glob_assigned_async_meth_ignore
    async def glob_assigned_async_meth_ignore(): pass
    global glob_assigned_async_meth_pep_695_ignore
    async def glob_assigned_async_meth_pep_695_ignore[T](): pass
c�\�|j�D]}|j�|k(s�|cSy�N)�get_children�get_name)�block�name�chs   �//usr/local/lib/python3.12/test/test_symtable.py�
find_blockr�s(��� � �"��
�;�;�=�D� ��I�#�c���eZdZejedd�Zeed�Zeed�Zeed�Z	ee	d�Z
ee	d�Zeed�Zeed	�Z
eed
�Zeed
�Zeed�Zeed�Zeed�Zeed�Zeed
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�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/y))*�SymtableTest�?�exec�Mine�a_method�spam�internal�other_internal�foo�Alias�GenericAlias�generic_spam�GenericMine�Tc��|j|jj�d�|j|jj�d�|j|jj�d�|j|j
j�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�y)N�module�class�functionz
type aliasztype parameterz
TypeVar bound)�assertEqual�top�get_typerrrrrrr�GenericAlias_innerr�generic_spam_innerr�GenericMine_innerr��selfs r
�	test_typezSymtableTest.test_type�s���������*�*�,�h�7�������+�+�-�w�7�������/�/�1�:�>�������+�+�-�z�:�������/�/�1�:�>�������*�*�,�j�9�������,�,�.��=�����*�*�3�3�5�7G�H�����0�0�9�9�;�\�J�����*�*�3�3�5�7G�H�����0�0�9�9�;�Z�H�����)�)�2�2�4�6F�G�����/�/�8�8�:�G�D���������*�O�<rc�L�|j|jj�d�|j|jj�d�|j|jj�d�|j|j
j�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�y)Nr)�
assertGreaterr!�get_idrrrrrrrrrr&s r
�test_idzSymtableTest.test_id�s&�����4�8�8�?�?�,�a�0����4�9�9�+�+�-�q�1����4�=�=�/�/�1�1�5����4�9�9�+�+�-�q�1����4�=�=�/�/�1�1�5����4�8�8�?�?�,�a�0����4�:�:�,�,�.��2����4�,�,�3�3�5�q�9����4�,�,�3�3�5�q�9����4�+�+�2�2�4�a�8rc��|j|jj��|j|jj��yr)�assertFalser!�is_optimized�
assertTruerr&s r
�test_optimizedzSymtableTest.test_optimized�s6��������.�.�0�1�����	�	�.�.�0�1rc�L�|j|jj��|j|jj��|j|jj��|j|jj��yr)r.r!�	is_nestedrrr0rr&s r
�test_nestedzSymtableTest.test_nested�sl��������+�+�-�.�������,�,�.�/�������,�,�.�/�����
�
�/�/�1�2rc��|j|jj��|j|jj��|j	|j
j��yr)r0r!�has_childrenrr.rr&s r
�
test_childrenzSymtableTest.test_children�sO��������-�-�/�0�����	�	�.�.�0�1�������.�.�0�1rc��|j|jj�d�|j|jj�d�y)Nr�)r r!�
get_linenorr&s r
�test_linenozSymtableTest.test_lineno�s<��������,�,�.��2�������-�-�/��4rc�v�|j}|jt|j��gd��gd�}|jt|j	��|�|jt|j��gd��|j|jj�d�y)N)�a�b�kw�var)r=r>rr?r�some_varr@�x)�bar�glob�some_assigned_global_var)rB)rr �sorted�get_parameters�
get_locals�get_globalsr�	get_frees)r'�func�expecteds   r
�test_function_infozSymtableTest.test_function_info�s����y�y������� 3� 3� 5�6�8O�P�Y��������� 1�2�H�=������ 0� 0� 2�3�5`�a�������0�0�2�F�;rc���|j|jjd�j��|j	|jjd�j��|j|jjd�j��|j|jjd�j��|j	|jjd�j��|j	|jjd�j��|j|jjd�j��|j|jjd�j��|j|jjd�j��y)NrDrCrB�instance_var�some_non_assigned_global_varrE)	r0r�lookup�	is_globalr.�is_declared_globalrrr!r&s r
�test_globalszSymtableTest.test_globals�sJ������	�	�(�(��0�:�:�<�=�������)�)�&�1�D�D�F�G�����	�	�(�(��/�9�9�;�<�����	�	�(�(��/�B�B�D�E�������-�-�c�2�<�<�>�?�������)�)�.�9�C�C�E�F�����	�	�(�(��/�9�9�;�<���������(F�G�Q�Q�S�T���������(B�C�M�M�O�Prc�<�|j|jjd�j��|j	|j
jd�j��d}|j
|j
j�|�y)NrA)rA)r.rrQ�is_nonlocalr0rr �
get_nonlocals�r'rLs  r
�
test_nonlocalzSymtableTest.test_nonlocal	sr��������)�)�*�5�A�A�C�D�����+�+�2�2�:�>�J�J�L�M� ������,�,�:�:�<�h�Grc���|j|jjd�j��|j	|jjd�j��|j|j
jd�j��|j|j
jd�j��y)NrBrCrPrE)r0rrQ�is_localr.r!r&s r
�
test_localzSymtableTest.test_locals�������	�	�(�(��-�6�6�8�9�������)�)�%�0�9�9�;�<���������(F�G�P�P�R�S���������(B�C�L�L�N�Orc�t�|j|jjd�j��y)NrB)r0rrQ�is_freer&s r
�	test_freezSymtableTest.test_frees&������
�
�,�,�S�1�9�9�;�<rc�T�|j|jjd�j��|j|jjd�j��|j|jjd�j��y)NrBr)r0rrQ�
is_referencedrr.r&s r
�test_referencedzSymtableTest.test_referencedsp������
�
�,�,�S�1�?�?�A�B�����	�	�(�(��4�B�B�D�E�������)�)�#�.�<�<�>�?rc���dD]:}|j|jj|�j���<|j	|jjd�j��y)N)r=r@r?rB)r0rrQ�is_parameterr.)r'�syms  r
�test_parameterszSymtableTest.test_parameterssV��%�C��O�O�D�I�I�,�,�S�1�>�>�@�A�&�������)�)�#�.�;�;�=�>rc��|jt|jj��t|jj	���|jt|jjd�y)N�not_here)r �lenr!�get_identifiers�get_symbols�assertRaises�KeyErrorrQr&s r
�test_symbol_lookupzSymtableTest.test_symbol_lookup#sU������T�X�X�5�5�7�8��T�X�X�1�1�3�4�	6�	
���(�D�H�H�O�O�Z�@rc��|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|j
jd�j��|j|jjd�j��|j
|j
jd�j��|j|jjd�j�|j
u�|jjd�}|jt|j��d�|jt|j�|jjd�}|jt|j��d	�|jt|j�y)
Nrrrr�namespace_testrB�rDr)
r0r!rQ�is_namespacerrr.�
get_namespacer ri�get_namespacesrl�
ValueError)r'�ns_test�	ns_test_2s   r
�test_namespaceszSymtableTest.test_namespaces)s������������/�<�<�>�?�����	�	�(�(��4�A�A�C�D����������/�<�<�>�?�����	�	�(�(��4�A�A�C�D���������(8�9�F�F�H�I�������)�)�#�.�;�;�=�>����������/�=�=�?�4�9�9�L�M��(�(�/�/�"2�3������W�3�3�5�6��:����*�g�&;�&;�<��H�H�O�O�F�+�	�����Y�5�5�7�8�!�<����*�i�&=�&=�>rc�4�|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|j
jd�j��|j
|jjd�j��y)NrBrCrr)r0rrQ�is_assignedr!rr.rr&s r
�
test_assignedzSymtableTest.test_assigned:s�������	�	�(�(��-�9�9�;�<�����	�	�(�(��/�;�;�=�>����������/�;�;�=�>�����	�	�(�(��4�@�@�B�C�������-�-�c�2�>�>�@�Arc�0�tjddd�}|j�d}|j|jd�j	��|j|jd�j��|j
|jd�j��tjddd�}|j�d}|j|jd�j	��|j
|jd�j��tjddd�}|j|jd�j��tjddd�}y)	Nzdef f():
    x: int
�testrrrBzdef f():
    x = 1
zglobal x
x: intz=def g():
    x = 2
    def f():
        nonlocal x
    x: int)�symtablerr0rQr[�is_annotatedr.rR)r'�st1�st2�st3�st4�st5�st6s       r
�test_annotatedzSymtableTest.test_annotatedAs9����� 8�&�&�I����� ��#������
�
�3��0�0�2�3�����
�
�3��4�4�6�7�������C��2�2�4�5���� 7���H����� ��#������
�
�3��0�0�2�3�������C��5�5�7�8���� 2�F�F�C������
�
�3��1�1�3�4����!-�
!'��0�rc�t�|j|jjd�j��y)N�sys)r0r!rQ�is_importedr&s r
�
test_importedzSymtableTest.test_importedZs$�����������.�:�:�<�=rc�r�|j|jj�d�|j|jj�d�|j|jj	d�j�d�|j|j
j�d�y)Nr!rrBr)r r!rrrQrr&s r
�	test_namezSymtableTest.test_name]s���������*�*�,�e�4�������+�+�-�v�6�������)�)�#�.�7�7�9�3�?�������+�+�-�v�6rc
����j�jj�d�tjtdd�}t|d�}�j|j�d��fd�}d}|D]v}�j
|��5||d	�ddd��j
|d
��5|dj|d
f�d	�|djd
|f�d	�ddd��xdD]�}d|�d�d|�d�d|�d�d|�d�fD]}}�j
|��5||d�ddd�|D]R}�j
||��5|dj||f�d�|dj||f�d�ddd��T���y#1swY��xYw#1swY��-xYw#1swY�~xYw#1swY��xYw)N)rrr�ComplexClass)r�a_method_pep_695�an_async_method�an_async_method_pep_695�
a_classmethod�a_classmethod_pep_695�an_async_classmethod�an_async_classmethod_pep_695�a_staticmethod�a_staticmethod_pep_695�an_async_staticmethod�an_async_staticmethod_pep_695�a_fakemethod�a_fakemethod_pep_695�an_async_fakemethod�an_async_fakemethod_pep_695�glob_unassigned_meth�glob_unassigned_meth_pep_695�glob_unassigned_async_meth�"glob_unassigned_async_meth_pep_695�glob_assigned_meth�glob_assigned_meth_pep_695�glob_assigned_async_meth� glob_assigned_async_meth_pep_695c���tj|d�}tjd|��dd�}t|d�}�j	|j�|�y)Nz    z	class A:
rr�A)�textwrap�indentr~rr �get_methods)�body�expected_methods�indentedr!�thisr's     �r
�
check_bodyz7SymtableTest.test_class_get_methods.<locals>.check_bodysT������t�W�5�H��#�#�j��
�$;�S�&�I�C��c�3�'�D����T�-�-�/�1A�Br)zx = (x for x in [])zx = (x async for x in [])zgenexpr = (x for x in [])zgenexpr = (x async for x in []))�gen�T)r��isvar�
zgenexpr = 1)z()z(x)z(x, y)z(z: T)zdef genexprz:passzasync def genexprzdef genexpr[T]zasync def genexpr[T])rK)�genexpr)r�rK)r rr�r~�TEST_COMPLEX_CLASS_CODEr�subTest�join)r'r!r�r��GENEXPRSr��	paramlistrKs`       r
�test_class_get_methodsz#SymtableTest.test_class_get_methodscs����������.�.�0�-�@���� 7��f�E���#�~�.������)�)�+�
.
�
	�,	C�
���C����#��&��3��#�'����#�T��2��4�9�9�c�=�%9�:�B�?��4�9�9�m�S�%9�:�B�?�3�2�
�;�I��i�[��.�#�I�;�e�4� ���5�1�&�y�k��7�	���\�\�t�\�,��t�\�2�-�$�C����#�D��9�"�4�9�9�c�4�[�#9�<�H�"�4�9�9�d�C�[�#9�<�H�:�9�$��;�'�&��3�2��-�,��
:�9�s0�
F�65F�%
F,�5F8	�F	�F)	�,F5�8G
c����fd�}|dd�|dd�tjddd��jt�5tjdtd�d�ddd��jt�5tjdt	d�d�ddd��jt�5tjdtd�d�ddd�y#1swY��xYw#1swY�TxYw#1swYyxYw)	Nc�2��	tj|dd��jd|���y#t$r^}�j|jd��j|j
d��j|j|�Yd}~yd}~wwxYw)Nrrzno SyntaxError for �)r~�fail�SyntaxErrorr �filename�lineno�offset)�
brokencoder��er's   �r
�
checkfilenamez9SymtableTest.test_filename_correct.<locals>.checkfilename�s}���
C��!�!�*�f�f�=��	�	�Z�A�B���
3�� � ����V�4�� � ����1�-�� � ����6�2�2��
3�s�/�	B�AB�Bzdef f(x): foo)(r9zdef f(x): global x��passsspamr)r~rl�	TypeError�	bytearray�
memoryview�list)r'r�s` r
�test_filename_correctz"SymtableTest.test_filename_correct�s����	C�	�'��,��*�B�/����&�'�6�2�
�
�
�y�
)����f�i��&8�&�A�*�
�
�
�y�
)����f�j��&9�6�B�*�
�
�
�y�
)����f�d�7�m�V�<�*�
)�	*�
)��
)�
)��
)�
)�s$�!C+�!C7�!D�+C4�7D�Dc�2�tjddd�}y)N�42r�eval�r~�r'�symbolss  r
�	test_evalzSymtableTest.test_eval�s���#�#�D�#�v�6�rc�2�tjddd�}y)Nr�r�singler�r�s  r
�test_singlezSymtableTest.test_single�s���#�#�D�#�x�8�rc�2�tjddd�}y)Nzdef f(x): return xrrr�r�s  r
�	test_execzSymtableTest.test_exec�s���#�#�$8�#�v�F�rc��tjtjd�dd�}|jt	|d��d}tj|dd�}|jt	|d��y)N�utf8rrrs+# -*- coding: iso8859-15 -*-
class �: pass
uŽ)r~�	TEST_CODE�encode�assertIsNotNoner)r'r!�codes   r
�
test_byteszSymtableTest.test_bytes�sd�����	� 0� 0�� 8�#�v�F�����Z��V�4�5�B������c�6�2�����Z��X�6�7rc��|jt|j�d�|jt|j�d�y)Nz<SymbolTable for module ?>z$<Function SymbolTable for spam in ?>)r �strr!rr&s r
�test_symtable_reprzSymtableTest.test_symtable_repr�s4������T�X�X��(D�E�����T�Y�Y��)O�Prc���d|jj��d|jj��d�}|jt	|jj
�|�y)Nz<symtable entry top(z), line �>)r!r+r:r �repr�_tablerXs  r
�test_symtable_entry_reprz%SymtableTest.test_symtable_entry_repr�sN��)�$�(�(�/�/�*;�)<�H�T�X�X�EX�EX�EZ�D[�[\�]������d�h�h�o�o�.��9rN)0�__name__�
__module__�__qualname__r~r�r!rrrrrrrrrr#rr$rr%rr(r,r1r4r7r;rMrTrYr\r_rbrfrnrxr{r�r�r�r�r�r�r�r�r�r�r�r�rr
rr�sV��
�(�
�
�I�s�F�
3�C��c�6�"�D��$�
�+�H��c�6�"�D��$�
�+�H���&6�7�N�
�S�%�
 �C��s�G�$�E��c�>�2�L�#�L�.�A���c�>�2�L�#�L�.�A���S�-�0�K�"�;�
�>���;��$�A�=� 
9�2�
3�2�
5�<�
Q�H�P�=�@�
?�
A�?�"B�0�2>�7�CI�J=�,7�9�G�8�Q�:rr�__main__)�__doc__r�r~�unittestr�r�r�TestCaserr��mainr�rr
�<module>r�s[������+
�	�Zp��f�e:�8�$�$�e:�P	�z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists