Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/test/test_lib2to3/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/test/test_lib2to3/__pycache__/test_util.cpython-312.opt-2.pyc

�

)Μg�R����	ddlmZddlmZmZddlmZddlmZm	Z	m
Z
mZddlm
Z
dd�ZGd�d	ej�ZGd
�dej�ZGd�d
ej�ZGd�de�ZGd�de�ZGd�de�ZGd�dej�ZGd�dej�ZGd�dej�ZGd�dej�Zy)�)�support�)�Node�Leaf)�
fixer_util)�Attr�Name�Call�Comma)�tokenc�|�tj|�}t|�D]}|jd}�d|_|S)Nr)r�parse_string�range�children�parent)�code�strip_levels�tree�is    �8/usr/local/lib/python3.12/test/test_lib2to3/test_util.py�parsers=������%�D�
�<�
 ���}�}�Q���!��D�K��K�c��eZdZd�Zy)�
MacroTestCasec��t|ttf�r$ttj
j|�}|jt|�|�y�N)	�
isinstance�tuple�listrr�syms�simple_stmt�assertEqual�str)�self�node�strings   r�	assertStrzMacroTestCase.assertStrs:���d�U�D�M�*��
���3�3�T�:�D�����T��F�+rN)�__name__�
__module__�__qualname__r'�rrrrs��,rrc��eZdZd�Zd�Zd�Zy)�
Test_is_tuplec�B�tjt|d���S�N��r)r�is_tupler�r$r&s  rr2zTest_is_tuple.is_tuples���"�"�5��a�#@�A�Arc�D�|j|jd��|j|jd��|j|jd��|j|jd��|j|jd��y)Nz(a, b)z(a, (b, c))z((a, (b, c)),)z(a,)z())�
assertTruer2�r$s r�
test_validzTest_is_tuple.test_valid sl������
�
�h�/�0�����
�
�m�4�5�����
�
�&6�7�8�����
�
�f�-�.�����
�
�d�+�,rc��|j|jd��|j|jd��y)Nz(a)z('foo') % (b, c))�assertFalser2r6s r�test_invalidzTest_is_tuple.test_invalid's1��������u�-�.�������'9�:�;rN)r(r)r*r2r7r:r+rrr-r-s��B�-�<rr-c��eZdZd�Zd�Zd�Zy)�Test_is_listc�B�tjt|d���Sr/)r�is_listrr3s  rr>zTest_is_list.is_list-s���!�!�%��Q�"?�@�@rc�D�|j|jd��|j|jd��|j|jd��|j|jd��|j|jd��y)Nz[]z[a]z[a, b]z[a, [b, c]]z[[a, [b, c]],])r5r>r6s rr7zTest_is_list.test_valid0sl��������T�*�+�������U�+�,�������X�.�/�������]�3�4�������%5�6�7rc�D�|j|jd��y)Nz[]+[])r9r>r6s rr:zTest_is_list.test_invalid7s��������g�.�/rN)r(r)r*r>r7r:r+rrr<r<,s��A�8�0rr<c��eZdZd�Zd�Zy)�	Test_Attrc���tdd��}|jttd�td��d�|jt|td��d�y)Nzfoo()r0r1�a�b�a.bzfoo().b)rr'rr	)r$�calls  r�testzTest_Attr.test<sD���W�1�-�����t�D��I�t�C�y�1�5�9����t�D�$�s�)�,�i�8rc�~�ttd�td��}|jt|�t�y)NrDrE)rr	r"�typer)r$�attrs  r�test_returnszTest_Attr.test_returnsBs*���D��I�t�C�y�)������d��T�*rN)r(r)r*rHrLr+rrrBrB;s��9�+rrBc��eZdZd�Zy)�	Test_Namec��|jtd�d�|jtd�d�|jtdd��d�y)NrDz
foo.foo().barrE��prefix�ba)r'r	r6s rrHzTest_Name.testHs<�����t�C�y�#�&����t�O�,�o�>����t�C��,�d�3rN)r(r)r*rHr+rrrNrNGs��4rrNc��eZdZdd�Zd�Zy)�	Test_CallNc���	g}t|t�rA|D],}|j|�|jt���.|j	�tt
|�||�Sr)rr�appendr�popr
r	)r$�name�argsrQr�args      r�_CallzTest_Call._CallOsV�� ����d�D�!�������$������(��
�L�L�N��D��J��&�1�1rc	��dttjd�ttjd�ttjd�gttjd�ttjd�ttjd�ttjd�gttjd�ttjdd��gg}|j	|jd	�d
�|j	|jd|d�d�|j	|jd|d�d
�|j	|jd|dd��d�y)Nrr0��rE�j� rP�AzA()zb(1,2,3)za.b().cza.b().c(1,3,2,4)�dz d(b, j))rr�NUMBER�STRINGr'r[)r$�kidss  rrHzTest_Call.testYs	����e�l�l�A�&��U�\�\�1�(=��e�l�l�A�&�(��e�l�l�A�&��U�\�\�1�(=��e�l�l�A�&��U�\�\�1�(=�?��e�l�l�C�(�$�u�|�|�S��*M�N���	
���t�z�z�#���.����t�z�z�#�t�A�w�/��<����t�z�z�)�T�!�W�5�7I�J����t�z�z�#�t�A�w�s�z�;�Z�Hr)NN)r(r)r*r[rHr+rrrTrTNs
��2�IrrTc�$�eZdZd�Zd�Zd�Zd�Zy)�Test_does_tree_importc��tj||�}|r|S|jD]}|j||�}|s�|cSyr)r�find_bindingr�_find_bind_rec)r$rXr%�c�childs     rrjz$Test_does_tree_import._find_bind_rechsD��
�#�#�D�$�/���Q�h��]�]�E��#�#�D�%�0�A���(�#rc�j�t|�}|jd|�}tj|||�S)N�start)rrjr�does_tree_import)r$�packagerXr&r%s     rroz&Test_does_tree_import.does_tree_importqs2���V�}���"�"�7�D�1���*�*�7�D�$�?�?rc��d}|D]Z\}}}|j|||dz|z�}|j|�|j|||dz|z�}|j|��\d}|D]Z\}}}|j|||dz|z�}|j|�|j|||dz|z�}|j|��\y)N))rDrD�from a import b)�a.drD�from a.d import b)zd.arD�from d.a import b)NrD�import b)NrD�import b, c, d�
))rDrD�from a import a)�xrD�from x import a)rzrD�from x import b, c, a, d)�x.brD�from x.b import a)r}rD�from x.b import b, c, a, d)NrD�import a)NrD�import b, c, a, d)ror9r5)r$r&�
failing_testsrprX�import_�n�
passing_testss        r�try_withzTest_does_tree_import.try_withws���8�
�
'4�"�G�T�7��%�%�g�t�W�t�^�f�5L�M�A����Q���%�%�g�t�V�d�]�W�5L�M�A����Q��	'4�;�
�'4�"�G�T�7��%�%�g�t�W�t�^�f�5L�M�A��O�O�A���%�%�g�t�V�d�]�W�5L�M�A��O�O�A��	'4rc�&�|jd�y)Nzdef foo():
	bar.baz()
	start=3)r�r6s r�test_in_functionz&Test_does_tree_import.test_in_function�s���
�
�:�;rN)r(r)r*rjror�r�r+rrrgrggs���@��2<rrgc��eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�Test_find_bindingNc�B�tj|t|�|�Sr)rrir)r$rXr&rps    rrizTest_find_binding.find_binding�s���&�&�t�U�6�]�G�D�Drc��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��y)NrDza = bz
a = [b, c, d]z	a = foo()za = foo().foo.foo[6][foo]zfoo = azfoo = (a, b, c)�r5rir9r6s r�test_simple_assignmentz(Test_find_binding.test_simple_assignment�s�������)�)�#�w�7�8�����)�)�#��?�@�����)�)�#�{�;�<�����)�)�#�/J�K�L�����*�*�3�	�:�;�����*�*�3�0A�B�Crc��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��y)NrDz(a,) = bz(a, b, c) = [b, c, d]z(c, (d, a), b) = foo()z(a, b) = foo().foo[6][foo]z(foo, b) = (b, a)z(foo, (b, c)) = (a, b, c)r�r6s r�test_tuple_assignmentz'Test_find_binding.test_tuple_assignment�s�������)�)�#�z�:�;�����)�)�#�/F�G�H�����)�)�#�/G�H�I�����)�)�#�/K�L�M�����*�*�3�0C�D�E�����*�*�3�0K�L�Mrc��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��y)NrDz[a] = bz[a, b, c] = [b, c, d]z[c, [d, a], b] = foo()z[a, b] = foo().foo[a][foo]z[foo, b] = (b, a)z[foo, [b, c]] = (a, b, c)r�r6s r�test_list_assignmentz&Test_find_binding.test_list_assignment�s�������)�)�#�y�9�:�����)�)�#�/F�G�H�����)�)�#�/G�H�I�����)�)�#�/K�L�M�����*�*�3�0C�D�E�����*�*�3�0K�L�Mrc��|j|jdd��|j|jdd��|j|jdd��|j|jdd��y)NrDz	foo.a = 5z
foo[a] = 5z
foo(a) = 5z
foo(a, b) = 5�r9rir6s r�test_invalid_assignmentsz*Test_find_binding.test_invalid_assignments�sn������*�*�3��<�=�����*�*�3��=�>�����*�*�3��=�>�����*�*�3��@�Arc��|j|jdd��|j|jdd��|j|jdd��|j|jdd��y)NrDr�r�rvrwr�r6s r�test_simple_importz$Test_find_binding.test_simple_import�sl������)�)�#�z�:�;�����)�)�#�/B�C�D�����*�*�3�
�;�<�����*�*�3�0@�A�Brc��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd	��y)
NrDr{ryr|r~rrrrtrur�r6s r�test_from_importz"Test_find_binding.test_from_import�s�������)�)�#�/@�A�B�����)�)�#�/@�A�B�����)�)�#�/I�J�K�����)�)�#�/B�C�D�����)�)�#�/K�L�M�����*�*�3�0A�B�C�����*�*�3�0C�D�E�����*�*�3�0C�D�Erc��|j|jdd��|j|jdd��|j|jdd��|j|jdd��y)NrDz
import b as azimport b as a, c, a as f, d�
import a as fzimport b, c as f, d as er�r6s r�test_import_asz Test_find_binding.test_import_as�sl������)�)�#��?�@�����)�)�#�/L�M�N�����*�*�3��@�A�����*�*�3�0J�K�Lrc���|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��y)	NrD�from x import b as a�from x import g as a, d as b�from x.b import t as a�from x.b import g as a, d�from a import b as tzfrom a.d import b as tzfrom d.a import b as tr�r6s r�test_from_import_asz%Test_find_binding.test_from_import_as�s�������)�)�#�/E�F�G�����)�)�#�/M�N�O�����)�)�#�/G�H�I�����)�)�#�/J�K�L�����*�*�3�0F�G�H�����*�*�3�0H�I�J�����*�*�3�0H�I�Jrc��|j|jdd��|j|jdd��|j|jddd��|j|jddd��y)NrErvrwrkr�r6s r�test_simple_import_with_packagez1Test_find_binding.test_simple_import_with_package�sp������)�)�#�z�:�;�����)�)�#�/?�@�A�����*�*�3�
�C�@�A�����*�*�3�0@�#�F�Grc���|j|jddd��|j|jddd��|j|jddd��|j|jddd��|j|jddd��|j|jdd	d��|j|jdd
d��|j|jddd��|j|jddd
��|j|jddd
��|j|jddd��y)NrDr{rzryzfrom x import *r|r~r}zfrom x.b import *rrrrtrsruzfrom x.y import *rFr�r6s r�test_from_import_with_packagez/Test_find_binding.test_from_import_with_package�s>������)�)�#�/@�#�F�G�����)�)�#�/@�#�F�G�����)�)�#�/@�#�F�G�����)�)�#�/I�3�O�P�����)�)�#�/B�E�J�K�����)�)�#�/B�E�J�K�����)�)�#�/K�U�S�T�����*�*�3�0A�3�G�H�����*�*�3�0C�U�K�L�����*�*�3�0C�U�K�L�����*�*�3�0C�U�K�Lrc���|j|jddd��|j|jddd��|j|jddd��y)NrDzimport b.c as azb.cr��fr�r6s r�test_import_as_with_packagez-Test_find_binding.test_import_as_with_package�sZ������*�*�3�0A�5�I�J�����*�*�3���E�F�����*�*�3���E�Frc���|j|jddd��|j|jddd��|j|jddd��|j|jddd��|j|jddd��|j|jddd	��|j|jddd
��y)NrDr�rzr�r�r}r�r�rE�tr�r6s r� test_from_import_as_with_packagez2Test_find_binding.test_from_import_as_with_package�s���	
����*�*�3�0F��L�M�����*�*�3�0N�PS�T�U�����*�*�3�0H�%�P�Q�����*�*�3�0K�U�S�T�����*�*�3�0F��L�M�����*�*�3�0F��L�M�����*�*�3�0F��L�Mrc��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��d	}|j|jd|��y)
NrDz
def a(): passzdef a(b, c, d): passzdef a(): b = 7zdef d(b, (c, a), e): passzdef d(a=7): passzdef d(a): passzdef d(): a = 7zG
            def d():
                def a():
                    passr��r$�ss  r�test_function_defz#Test_find_binding.test_function_def�s�������)�)�#��?�@�����)�)�#�/E�F�G�����)�)�#�/?�@�A�����*�*�3�0K�L�M�����*�*�3�0B�C�D�����*�*�3�0@�A�B�����*�*�3�0@�A�B�
��	
����*�*�3��2�3rc���|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd	��|j|jdd
��|j|jdd��d}|j|jd|��y)
NrDz
class a: passzclass a(): passzclass a(b): passzclass a(b, c=8): passz
class d: passzclass d(a): passzclass d(b, a=7): passzclass d(b, *a): passzclass d(b, **a): passzclass d: a = 7zK
            class d():
                class a():
                    passr�r�s  r�test_class_defz Test_find_binding.test_class_defs4������)�)�#��?�@�����)�)�#�/@�A�B�����)�)�#�/A�B�C�����)�)�#�/F�G�H�����*�*�3��@�A�����*�*�3�0B�C�D�����*�*�3�0G�H�I�����*�*�3�0F�G�H�����*�*�3�0G�H�I�����*�*�3�0@�A�B�
��	
����*�*�3��2�3rc���|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��|j|jdd��y)	NrDzfor a in r: passzfor a, b in r: passzfor (a, b) in r: passzfor c, (a,) in r: passzfor c, (a, b) in r: passzfor c in r: a = czfor c in a: passr�r6s r�test_forzTest_find_binding.test_fors�������)�)�#�/A�B�C�����)�)�#�/D�E�F�����)�)�#�/F�G�H�����)�)�#�/G�H�I�����)�)�#�/I�J�K�����)�)�#�/B�C�D�����*�*�3�0B�C�Drc�4�d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d	}|j|jd|��y)
NzM
            for b in r:
                for a in b:
                    passrDzP
            for b in r:
                for a, c in b:
                    passzR
            for b in r:
                for (a, c) in b:
                    passzP
            for b in r:
                for (a,) in b:
                    passzU
            for b in r:
                for c, (a, d) in b:
                    passzN
            for b in r:
                for c in b:
                    a = 7zN
            for b in r:
                for c in b:
                    d = azN
            for b in r:
                for c in a:
                    d = 7r�r�s  r�test_for_nestedz!Test_find_binding.test_for_nested"s��
��	
����)�)�#�q�1�2�
��	
����)�)�#�q�1�2�
��	
����)�)�#�q�1�2�
��	
����)�)�#�q�1�2�
��	
����)�)�#�q�1�2�
��	
����)�)�#�q�1�2�
��	
����*�*�3��2�3�
��	
����*�*�3��2�3rc��|j|jdd��|j|jdd��y)NrDzif b in r: a = czif a in r: d = er�r6s r�test_ifzTest_find_binding.test_ifSs8������)�)�#�/A�B�C�����*�*�3�0B�C�Drc��d}|j|jd|��d}|j|jd|��y)NzL
            if b in r:
                if c in d:
                    a = crDzL
            if b in r:
                if c in d:
                    c = ar�r�s  r�test_if_nestedz Test_find_binding.test_if_nestedW�H��
��	
����)�)�#�q�1�2�
��	
����*�*�3��2�3rc��|j|jdd��|j|jdd��y)NrDzwhile b in r: a = czwhile a in r: d = er�r6s r�
test_whilezTest_find_binding.test_whileds8������)�)�#�/D�E�F�����*�*�3�0E�F�Grc��d}|j|jd|��d}|j|jd|��y)NzR
            while b in r:
                while c in d:
                    a = crDzR
            while b in r:
                while c in d:
                    c = ar�r�s  r�test_while_nestedz#Test_find_binding.test_while_nestedhr�rc��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��y)NzQ
            try:
                a = 6
            except:
                b = 8rDzQ
            try:
                b = 8
            except:
                a = 6z�
            try:
                b = 8
            except KeyError:
                pass
            except:
                a = 6�Q
            try:
                b = 8
            except:
                b = 6r�r�s  r�test_try_exceptz!Test_find_binding.test_try_exceptus���
��
	
����)�)�#�q�1�2�
��
	
����)�)�#�q�1�2�
��	
����)�)�#�q�1�2�
��
	
����*�*�3��2�3rc���d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��y)	Nz�
            try:
                try:
                    a = 6
                except:
                    pass
            except:
                b = 8rDz�
            try:
                b = 8
            except:
                try:
                    a = 6
                except:
                    passz�
            try:
                b = 8
            except:
                try:
                    pass
                except:
                    a = 6z�
            try:
                try:
                    b = 8
                except KeyError:
                    pass
                except:
                    a = 6
            except:
                passz�
            try:
                pass
            except:
                try:
                    b = 8
                except KeyError:
                    pass
                except:
                    a = 6r�a
            try:
                try:
                    b = 8
                except:
                    c = d
            except:
                try:
                    b = 6
                except:
                    t = 8
                except:
                    o = yr�r�s  r�test_try_except_nestedz(Test_find_binding.test_try_except_nested�s���
��	
����)�)�#�q�1�2�
��	
����)�)�#�q�1�2�
��	
����)�)�#�q�1�2�	
��	
����)�)�#�q�1�2�	
��	
����)�)�#�q�1�2�
��
	
����*�*�3��2�3�
��	
����*�*�3��2�3rc��d}|j|jd|��d}|j|jd|��d}|j|jd|��d}|j|jd|��y)Nz|
            try:
                c = 6
            except:
                b = 8
            finally:
                a = 9rDzR
            try:
                b = 8
            finally:
                a = 6zR
            try:
                b = 8
            finally:
                b = 6z|
            try:
                b = 8
            except:
                b = 9
            finally:
                b = 6r�r�s  r�test_try_except_finallyz)Test_find_binding.test_try_except_finally�s���
��	
����)�)�#�q�1�2�
��
	
����)�)�#�q�1�2�
��
	
����*�*�3��2�3�
��	
����*�*�3��2�3rc���d}|j|jd|��d}|j|jd|��d}|j|jd|��y)Nz�
            try:
                c = 6
            except:
                b = 8
            finally:
                try:
                    a = 9
                except:
                    b = 9
                finally:
                    c = 9rDz�
            try:
                b = 8
            finally:
                try:
                    pass
                finally:
                    a = 6z�
            try:
                b = 8
            finally:
                try:
                    b = 6
                finally:
                    b = 7r�r�s  r�test_try_except_finally_nestedz0Test_find_binding.test_try_except_finally_nestedsj��
��	
����)�)�#�q�1�2�
��	
����)�)�#�q�1�2�
��	
����*�*�3��2�3rr)r(r)r*rir�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r+rrr�r��s���E�D�N�N�B�C�F�M�K�H�M�G�

N�
4�4�$E�/4�bE�4�H�4�4�>K4�Z4�B!4rr�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�Test_touch_importc�~�td�}tjdd|�|jt	|�d�y)Nz"""foo"""
bar()�fooz"""foo"""
import foo
bar()

�rr�touch_importr"r#�r$r%s  r�test_after_docstringz&Test_touch_import.test_after_docstring's4���'�(������e�T�2�����T��$F�Grc�~�td�}tjdd|�|jt	|�d�y)Nz"""foo"""
import bar
bar()r�z'"""foo"""
import bar
import foo
bar()

r�r�s  r�test_after_importsz$Test_touch_import.test_after_imports,s4���3�4������e�T�2�����T��$R�Src�~�td�}tjdd|�|jt	|�d�y)N�bar()r�zimport foo
bar()

r�r�s  r�test_beginningz Test_touch_import.test_beginning1�2���W�~������e�T�2�����T��$;�<rc�~�td�}tjdd|�|jt	|�d�y)Nr��html�escapezfrom html import escape
bar()

r�r�s  rr�z"Test_touch_import.test_from_import6s2���W�~�������$�7�����T��$H�Irc�~�td�}tjdd|�|jt	|�d�y)Nr��cgizimport cgi
bar()

r�r�s  r�test_name_importz"Test_touch_import.test_name_import;r�rN)r(r)r*r�r�r�r�r�r+rrr�r�%s��H�
T�
=�
J�
=rr�c��eZdZd�Zd�Zy)�Test_find_indentationc��tj}td�}|j||�d�td�}|j||�d�y)Nznode()�)r�find_indentationrr"�r$�fir%s   r�test_nothingz"Test_find_indentation.test_nothingBsG��
�
(�
(���X�������D��2�&��R�y������D��2�&rc�|�tj}td�}|j||�d�|j||jdjdjd�d�td�}|j||jdjdjd�d�y)Nzdef f():
    x()r�rr^r0z    zdef f():
    x()
    y())rr�rr"rr�s   r�test_simplez!Test_find_indentation.test_simpleIs���
�
(�
(���(�)������D��2�&�����D�M�M�!�,�5�5�a�8�A�A�!�D�E�v�N��1�2������D�M�M�!�,�5�5�a�8�A�A�!�D�E�v�NrN)r(r)r*r�r�r+rrr�r�@s
��'�Orr�N)r)r�r�lib2to3.pytreerr�lib2to3r�lib2to3.fixer_utilrr	r
r�
lib2to3.pgen2rr�TestCaserr-r<rBrNrTrgr�r�r�r+rr�<module>r�s���-��&��6�6���,�G�$�$�,�
<�G�$�$�
<� 0�7�#�#�0�	+�
�	+�4�
�4�I�
�I�2*<�G�,�,�*<�XP4��(�(�P4�d=��(�(�=�6O�G�,�,�Or

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