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_pytree.cpython-312.opt-1.pyc

�

)Μg�?���dZddlmZddlmZ	eGd�dej�ZGd�d	ej�Z	y
#e$rd�ZY�5wxYw)aUnit tests for pytree.py.

NOTE: Please *don't* add doc strings to individual test methods!
In verbose mode, printing of the module, class and method name is much
more helpful than printing of (the first line of) the docstring,
especially when debugging a test.
�)�support�)�pytreec�<�t|�}|j�|S�N)�list�sort)�lst�ls  �:/usr/local/lib/python3.12/test/test_lib2to3/test_pytree.py�sortedr
s����I��	������c���eZdZdZd�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�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#y")#�	TestNodesz(Unit tests for nodes (Base, Leaf, Node).c��yr)�assertRaises�AssertionErrorr�Base)�selfs r�test_instantiate_basezTestNodes.test_instantiate_bases��rc��tjdd�}|j|jd�|j|jd�y)N�d�foo)r�Leaf�assertEqual�type�value�r�l1s  r�	test_leafzTestNodes.test_leaf"s:��
�[�[��e�
$��������#�&�������5�)rc�f�tjdd�}|jt|�d�y)NrrzLeaf(100, 'foo'))rrr�reprrs  r�test_leaf_reprzTestNodes.test_leaf_repr's'��
�[�[��e�
$������b��#5�6rc���tjdd�}|jt|�d�tjddd��}|jt|�d�y)Nrr)� )�
r��contextz foo)rrr�str)rr�l2s   r�
test_leaf_strzTestNodes.test_leaf_str+sL��
�[�[��e�
$������R��%�(�
�[�[��e�^�
<������R��&�)rc�t�tjdd�}d|_|jt	|�d�y)N���foo_�foo_5)rr�prefixrr)rs  r�test_leaf_str_numeric_valuez%TestNodes.test_leaf_str_numeric_value1s/���[�[��A�
����	�����R��'�*rc�$�tjdd�}tjddd��}|j||�tjdd�}tjdd�}|j||�|j||�y)Nrr�r%)rrr'�e�bar)rrr�assertNotEqual)rrr*�l3�l4s     r�test_leaf_equalityzTestNodes.test_leaf_equality8st��
�[�[��e�
$��
�[�[��e�]�
;������R� �
�[�[��e�
$��
�[�[��e�
$�����B��#����B��#rc��tjdd�}|j|jd�|j	|j
�d|_|j|jd�|j
|j
�y)Nrr�z  ##

)rrrr1�assertFalse�was_changed�
assertTruers  r�test_leaf_prefixzTestNodes.test_leaf_prefixAsc��
�[�[��e�
$��������B�'�������(���	�������J�/�������'rc��tjdd�}tjdd�}tjd||g�}|j|jd�|j|j
||g�y)Nrr��r6��)rr�Noderr�children�rrr*�n1s    r�	test_nodezTestNodes.test_nodeIsb��
�[�[��e�
$��
�[�[��e�
$��
�[�[���B�x�
(��������$�'�������r�2�h�/rc	��tjdd�}tjddd��}tjd||g�}|jt	|�dt	|��dt	|��d	��y)
Nrrr6r4r'rCzNode(1000, [z, z]))rrrDrr"rFs    r�test_node_reprzTestNodes.test_node_reprPs]��
�[�[��e�
$��
�[�[��e�]�
;��
�[�[���B�x�
(������b��37��8�T�"�X�F�	Hrc���tjdd�}tjddd��}tjd||g�}|jt	|�d�y)Nrrr6r4r'rCzfoo bar)rrrDrr)rFs    r�
test_node_strzTestNodes.test_node_strWsL��
�[�[��e�
$��
�[�[��e�]�
;��
�[�[���B�x�
(������R��)�,rc�L�tjdd�}|j|jd�tjd|g�}|j|jd�d|_|j|jd�|j|jd�y)Nrrr<rCr%)rrrr1rD)rrrGs   r�test_node_prefixzTestNodes.test_node_prefix]s{��
�[�[��e�
$��������B�'�
�[�[���t�
$��������B�'���	�������C�(�������C�(rc��tjddd��}tjddd��}tjd||g�}|j|j	�|j
�|j|j	�d�|j|j	�d�tjddd	��}tjd||g�}|j|j	�|j
�|j|j	�d�|j|j	�d�y)
Nrr�a�r1r6�brCr<�c)rrrDr�
get_suffixr1)rrr*rGr8�n2s      r�test_get_suffixzTestNodes.test_get_suffixfs���
�[�[��e�C�
0��
�[�[��e�C�
0��
�[�[���B�x�
(���������"�)�)�4��������"�-��������"�-�
�[�[��e�C�
0��
�[�[���B�x�
(���������"�)�)�4��������"�-��������"�-rc���tjdd�}tjdgd��}|j||�tjdd�}|j||�y)NrC�r4r'i�)rrDrr7)rrGrU�n3s    r�test_node_equalityzTestNodes.test_node_equalityvsT��
�[�[��r�
"��
�[�[��r�=�
9������R� �
�[�[��r�
"�����B��#rc�Z�tjdd�}tjdd�}tjd|g�}tjd|g�}|j||�tjdd�}tjd|g�}|j	||�y)NrrrCr6)rrrDrr7)rrr*rGrUr8rYs       r�test_node_recursive_equalityz&TestNodes.test_node_recursive_equality}s���
�[�[��e�
$��
�[�[��e�
$��
�[�[���t�
$��
�[�[���t�
$������R� �
�[�[��e�
$��
�[�[���t�
$�����B��#rc�p�tjdd�}tjdd�}tjdd�}tjd|||g�}|j|j|||g�|j|jt�|j|j�tjdd�}|j|�|j|j|||g�|j|jt�|j|j�y)Nrr�+r6rC�-)rrrDrrE�assertIsInstancerr=r>�replacer?)rrr*r8rG�l2news      r�test_replacezTestNodes.test_replace�s���
�[�[��e�
$��
�[�[��c�
"��
�[�[��e�
$��
�[�[���B��|�
,��������r�2�r�l�3����b�k�k�4�0�������(����C��%��
�
�
�5��������r�5�"�o�6����b�k�k�4�0�������'rc��tjdd�}tjdd�}tjdd�}tjd|||g�}|jtjdd�tjdd�g�|j	t|�d�|j
|jt�y)Nrrr^r6rC�*zfoo**bar)	rrrDrarr)r`rEr)rrr*r8rGs     r�test_replace_with_listz TestNodes.test_replace_with_list�s���
�[�[��e�
$��
�[�[��c�
"��
�[�[��e�
$��
�[�[���B��|�
,��
�
�
�F�K�K��S�)�6�;�;�s�C�+@�A�B�����R��*�-����b�k�k�4�0rc�n�tjdd�}tjdd�}tjdd�}tjd||g�}tjd|g�}tjd||g�}|jt	|j��|||g�y�Nrrr6�fooeyrC)rrrDrr�leaves)rrr*r8rUrYrGs       r�test_leaveszTestNodes.test_leaves�s���
�[�[��e�
$��
�[�[��e�
$��
�[�[��g�
&��
�[�[���B�x�
(��
�[�[���t�
$��
�[�[���B�x�
(������b�i�i�k�*�R��R�L�9rc��tjdd�}tjdd�}tjd||g�}tjdg�}tjd||g�}|j|j	�d�|j|j	�d�|j|j	�d�y)Nrrr6rCr-rr)rrrDr�depth)rrr*rUrYrGs      r�
test_depthzTestNodes.test_depth�s���
�[�[��e�
$��
�[�[��e�
$��
�[�[���B�x�
(��
�[�[��r�
"��
�[�[���B�x�
(���������Q�'��������Q�'��������Q�'rc�D�tjdd�}tjdd�}tjdd�}tjd||g�}tjd||g�}|jt	|j��|||||g�yrh)rrrDrr�
post_order�rrr*r8�c1rGs      r�test_post_orderzTestNodes.test_post_order�s���
�[�[��e�
$��
�[�[��e�
$��
�[�[��g�
&��
�[�[���B�x�
(��
�[�[���B�x�
(������b�m�m�o�.��R��R��0D�Erc�D�tjdd�}tjdd�}tjdd�}tjd||g�}tjd||g�}|jt	|j��|||||g�yrh)rrrDrr�	pre_orderrqs      r�test_pre_orderzTestNodes.test_pre_order�s���
�[�[��e�
$��
�[�[��e�
$��
�[�[��g�
&��
�[�[���B�x�
(��
�[�[���B�x�
(������b�l�l�n�-��B��B��/C�Drc���tjdd�}|j|j�|j	�|j|j�tjdd�}tjd|g�}|j|j�|j	�|j|j�tjdd�}tjdd�}tjdd�}tjd|||g�}tjd|g�}|j|j�|j|j�|j|j�|j	�|j|j�|j|j�|j|j�y)Nr�frCrr^r6)rrr=r>�changedr?rD)rrrGr*r8rUs      r�test_changedzTestNodes.test_changed�sS��
�[�[��c�
"��������(�
�
�
��������'�
�[�[��c�
"��
�[�[���t�
$��������(�
�
�
��������'�
�[�[��e�
$��
�[�[��c�
"��
�[�[��e�
$��
�[�[���B��|�
,��
�[�[���t�
$��������(�������(�������(�
�
�
��������'�������'�������(rc��dD]T}tjdd|��}|jt|�|dz�|j	|j
|��Vy)N��xyz_r<rrrQ)rrr?r)rr1)rr1rs   r�test_leaf_constructor_prefixz&TestNodes.test_leaf_constructor_prefix�sH��"�F����S�&��8�B��O�O�C��G�V�f�_�5����R�Y�Y��/�#rc��dD]�}tjdd�}tjddd��}tjd||g|��}|jt	|�|dz�|j|j|�|j|j|�|j|jd���y)	Nr|rrr�_rQrC�self_foo)rrrDr?r)rr1)rr1rr*rGs     r�test_node_constructor_prefixz&TestNodes.test_node_constructor_prefix�s���"�F����S�&�)�B����S�%��4�B����T�B��8�F�;�B��O�O�C��G�V�j�%8�9����R�Y�Y��/����R�Y�Y��/����R�Y�Y��,�#rc��tjdd�}tjdd�}tjd||g�}tjd|g�}|j|j	�d�|j|j
g�|j|j|�|j|jd�|j|jd�|j|j�|j|j�|j|j	�d�|j|j	�d�|j|j
g�|j|jd�|j|jd�|j|jd�|j|j�|j|j�y)NrrrCrr)
rrrDr�removerE�parentr=r>r?)rrr*rGrUs     r�test_removezTestNodes.test_remove�sl��
�[�[��e�
$��
�[�[��e�
$��
�[�[���B�x�
(��
�[�[���t�
$���������a�(�������b�)�������B�'�������D�)�������D�)�������(�������'��������a�(��������a�(�������b�)�������D�)�������D�)�������D�)�������'�������'rc��tjdg�}|j�|j|jd�tj
dd�}|j�|j|jd�y)NrCrr)rrDr�rr�r)rrGrs   r�test_remove_parentlessz TestNodes.test_remove_parentlesss\��
�[�[��r�
"��
�	�	��������D�)�
�[�[��e�
$��
�	�	��������D�)rc��tjdd�}tjd|g�}tjdd�}|jd|�|j	|j
d�|j	|j
|�|j	|j|g�tjd|g�}|jd|�|j	|j
d�|j	|j
|�|j	|j
d�|j	|j|g�|jt|jd|�|jt|jdt�y)NrrrCr6r�)rrrD�	set_childrr�rEr�
IndexError�	Exceptionr)rrrGr*rUs     r�test_node_set_childzTestNodes.test_node_set_childs"��
�[�[��e�
$��
�[�[���t�
$��
�[�[��e�
$��
���Q���������D�)�������B�'�������r�d�+�
�[�[���t�
$��
���Q���������D�)�������B�'�������D�)�������r�d�+����*�b�l�l�A�r�:����)�R�\�\�1�d�;rc��tjdd�}tjd|g�}tjdd�}|jd|�|j	|j
|�|j	|j||g�tjdd�}|jd|�|j	|j|||g�|jt|jdt�y)NrrrCr6r�abcr-)
rrrD�insert_childrr�rErr�r)rrrGr*r8s     r�test_node_insert_childz TestNodes.test_node_insert_child#s���
�[�[��e�
$��
�[�[���t�
$��
�[�[��e�
$��
����2��������B�'�������r�2�h�/�
�[�[��e�
$��
����2��������r�2�r�l�3�	
���)�R�_�_�a��>rc��tjdg�}tjdd�}|j|�|j	|j
|�|j	|j|g�tjdd�}|j|�|j	|j
|�|j	|j||g�|jt|jt�y)NrCrrr6)
rrDr�append_childrr�rErr�r)rrGrr*s    r�test_node_append_childz TestNodes.test_node_append_child3s���
�[�[��r�
"��
�[�[��e�
$��
�����������B�'�������r�d�+�
�[�[��e�
$��
�����������B�'�������r�2�h�/�	
���)�R�_�_�d�;rc�4�tjdg�}tjdg�}tjd||g�}|j|j|�|j	|jd�|j	|jd�y�NrC)rrD�assertIs�next_siblingr�rrGrU�p1s    r�test_node_next_siblingz TestNodes.test_node_next_siblingC�p��
�[�[��r�
"��
�[�[��r�
"��
�[�[���B�x�
(���
�
�b�o�o�r�*�������$�/�������$�/rc�4�tjdd�}tjdd�}tjd||g�}|j|j|�|j|jd�|j|jd�y�NrrPrRrC)rrrDr�r�r�rrr*r�s    r�test_leaf_next_siblingz TestNodes.test_leaf_next_siblingL�p��
�[�[��c�
"��
�[�[��c�
"��
�[�[���B�x�
(���
�
�b�o�o�r�*�������$�/�������$�/rc�4�tjdg�}tjdg�}tjd||g�}|j|j|�|j	|jd�|j	|jd�yr�)rrDr��prev_siblingrr�s    r�test_node_prev_siblingz TestNodes.test_node_prev_siblingUr�rc�4�tjdd�}tjdd�}tjd||g�}|j|j|�|j|jd�|j|jd�yr�)rrrDr�r�rr�s    r�test_leaf_prev_siblingz TestNodes.test_leaf_prev_sibling^r�rN)$�__name__�
__module__�__qualname__�__doc__rr r#r+r2r:r@rHrJrLrNrVrZr\rcrfrkrnrsrvrzr~r�r�r�r�r�r�r�r�r�r�rXrrrrs���2�;�
*�
7�*�+�$�(�0�H�-�)�.� $�$�(�1�:�	(�F�E�)�40�-�(�.*�<�*?� <� 0�0�0�0rrc�(�eZdZdZd�Zd�Zd�Zd�Zy)�TestPatternsz&Unit tests for tree matching patterns.c��tjdd�}tjdd�}tjdd�}tjd||g�}tjd|g�}tjd||g�}tjddd��}i}|j	|j||���|j
|i�|j	|j||���|j
|i�|j	|j||���|j
|i�|j|j||���|j
|d|i�i}|j	|j||���|j
|i�tjd|gd��}	|j	|	j||���|j
|i�|j	|	j||���|j
|i�|j|	j||���|j
|||d	��i}|j	|	j||���|j
|i�|j	|	j||���|j
|i�y)
Nrrr6rC�pl��name)�results�pn)r�r�)	rrrD�LeafPatternr=�matchrr?�NodePattern)
rrr*r8rGrU�rootr��rr�s
          r�test_basic_patternsz TestPatterns.test_basic_patternslsX��
�[�[��e�
$��
�[�[��e�
$��
�[�[��e�
$��
�[�[���B�x�
(��
�[�[���t�
$���{�{�4�"�b��*��
�
�
��U��
6����������$���2�3�����B��������"�a��0�1�����B��������"�a��0�1�����B���������Q��/�0�����T�2�J�'���������"�a��0�1�����B��
�
�
��r�d��
6��������$���2�3�����B��������"�a��0�1�����B���������Q��/�0�����2�R�0�1���������"�a��0�1�����B��������"�a��0�1�����B�rc�r�tjdd�}tjdd�}tjdd�}tjd||g�}tjd|g�}tjd||g�}tjddd��}tjd|gd��}tj
|g||ggd��}	i}
|j
|	j|g|
��|j|
i�|j
|	j|g|
��|j|
i�|j|	j|g|
��|jt|
j��gd	��|j|
d|�|j|
d|�|j|
d|g�|j|
|||gd	��i}
|j|	j||g|
��|j|
|||gd
��|j|
d|�i}
y)Nrrr6rCr�r�r��pw)r�r�r�)r�r�)
rrrDr�r��WildcardPatternr=�	match_seqrr?r
�keysr�)rrr*r8rGrUr�r�r�r�r�s           r�
test_wildcardzTestPatterns.test_wildcard�s���
�[�[��e�
$��
�[�[��e�
$��
�[�[��e�
$��
�[�[���B�x�
(��
�[�[���t�
$���{�{�4�"�b��*��
�
�
��U��
6��
�
�
��r�d��
6��
�
#�
#�b�T�B��8�$4�4�
@����������t�f�a�0�1�����B��������r�d�A�.�/�����B��������b�T�1�-�.���������)�+=�>�����4��"�%�����4��"�%�����4��2�$�'�����2�R��t�<�=���������b�"�X�q�1�2�����2�b�"�X�6�7��
�
�a��g�r�"��rc	���tjdd�}tjdd�}tjdd�}tjdd�}tjdd�}tjdd�}||||||g}tjd|�}tjddd	�}	tjddd
�}
tjddd�}tjddd�}tjddd
�}
tjddd�}tj|	|
|g||
g|	|
g||g|
|ggddd��}|j|j
|�D�cgc]}|d��	c}gd��tjd|gd��}ttj|g|g��}|jt|�d�|d\}}|j|d�|jt|d�d�|j|d||||||g�dD].}|j|d|ztjd|���0ycc}w)NrrPrRrS�d�erxrC�pa�pb�pc�pd�pe�pfr�r�)�min�maxr�r)�r.r-r���pr)r�contentr��abcdef�p)rrrDr�r�r�generate_matchesr�r�lenr))r�la�lb�lc�ld�le�lfrjr�r�r�r�r�r�r�r��xr��matchesrSr�s                     r�test_generate_matchesz"TestPatterns.test_generate_matches�s=��
�[�[��C�
 ��
�[�[��C�
 ��
�[�[��C�
 ��
�[�[��C�
 ��
�[�[��C�
 ��
�[�[��C�
 ���b�"�b�"�b�)���{�{�4��(��
�
�
��3��
-��
�
�
��3��
-��
�
�
��3��
-��
�
�
��3��
-��
�
�
��3��
-��
�
�
��3��
-��
�
#�
#�b�"�b�\�B��8�&(�"�X��B�x�"�b��%C�()�q�t�=��	
����(;�(;�F�(C�D�(C�1�!�A�$�(C�D�(�	*�
�
�
�T�B�4�d�
C���v�.�.��t�d�V�<�=������W��q�)��q�z���1�����A������Q�t�W��x�0�����4��2�r�2�r�2�r�":�;��A����Q�s�Q�w�Z����Q��):�;���Es�4I&c���tjdtjd�tjd��tjd�f�}tjdd�}tjdd�}tjdd	�}tj
d|||g�}i}|j
|j||��|j|d|g�y)
NiK��argsr���(r�r��))	rr�r�r�rrDr?r�r)r�patternrr*r8�noder�s       r�test_has_key_examplez!TestPatterns.test_has_key_example�s����$�$�S�&,�&8�&8��&;�&,�&<�&<�&�&I�&,�&8�&8��&;�&=�>���[�[��C�
 ��
�[�[��C�
 ��
�[�[��C�
 ���{�{�3��R���-��������
�
�d�A�.�/�����6��R�D�)rN)r�r�r�r�r�r�r�r�rXrrr�r�hs��0�" �H�><�<*rr�N)
r�r<r�lib2to3rr
�	NameError�TestCaserr�rXrr�<module>r�sZ������
�L0�� � �L0�^
p*�7�#�#�p*��k
����s�=�A�A

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