Sindbad~EG File Manager

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

�

'Μgj����ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZddlmZmZddlmZddlmZdd	lmZmZmZmZmZm Z Gd
�de	jB�Z"Gd�d
e	jB�Z#Gd�de	jB�Z$Gd�de	jB�Z%Gd�de	jB�Z&Gd�d�Z'Gd�de'e	jB�Z(Gd�dee'e	jB�Z)ejTGd�de	jB��Z+Gd�de	jB�Z,y)�N)�partial)�dedent)�support)�import_fresh_module)�	os_helper�
script_helper)�ASTTestMixin)�to_tuple)�
eval_tests�eval_results�
exec_tests�exec_results�single_tests�single_resultsc���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#d"�Z$e%jLd#��Z'd$�Z(d%�Z)d&�Z*d'�Z+d(�Z,d)�Z-d*�Z.d+�Z/d,�Z0d-�Z1d.�Z2e3jhe%jjd/�e%jLd0���Z6d1�Z7d2e8e9jtd3e;d4e;d5dfd6�Z<d8d7�Z=y)9�	AST_TestsNc�v�t|t�syd|jvry|dk7xr|dj�S)NF�ast�ASTr)�
isinstance�type�
__module__�isupper)�self�name�nodes   �3/usr/local/lib/python3.12/test/test_ast/test_ast.py�_is_ast_nodezAST_Tests._is_ast_nodes8���$��%������'���u�}�2��a����!2�2�c��t|tj�r|j�yt|tjtj
tjf�rB|j|jf}|j||�|j|jf}|jD]t}t||�}t|t�rA|}|r#|dk(r|dj|djf}|D]}|j||���`|��c|j||��v|j|j|j�y)N�decorator_listr)rrr�_fields�expr�stmt�
excepthandler�lineno�
col_offset�assertGreaterEqual�getattr�list�_assertTrueorder�assertEqual�__match_args__)r�ast_node�
parent_pos�node_posr�value�	first_pos�childs        rr+zAST_Tests._assertTrueorder$s���(�C�G�G�,��0@�0@�0H���h����3�8�8�S�5F�5F� G�H� ����)<�)<�=�H��#�#�H�j�9�"�/�/�8�+>�+>�?�J��$�$�D��H�d�+�E��%��&�&�	��T�%5�5�!&�q����%��(�2E�2E� F�I�"�E��)�)�%��;�#��"��%�%�e�Z�8�%�	
����)�)�8�+B�+B�Crc���tj�}|j|jd�d|_|j|jd�|j|j
dd�|j
t�5|jddd�|j
t�5tjd�ddd�y#1swY�=xYw#1swYyxYw)N��*�foobar�)
rrr,r"r7�__dict__�assertRaises�AttributeError�vararg�	TypeError�r�xs  r�test_AST_objectszAST_Tests.test_AST_objects7s����G�G�I��������B�'����������2�&�������H�-�r�2�
�
�
�~�
.�
�H�H�/��
�
�y�
)��G�G�A�J�*�
)�/�
.��*�
)�s�
C�2C�C�C&c��Gd�d�}tj�}|�|_||j_t	j
|j�}~t
j�|j|��y)Nc��eZdZy)�0AST_Tests.test_AST_garbage_collection.<locals>.XN��__name__r�__qualname__r5rr�XrCF���rrG)	rrr?�a�weakref�refr�
gc_collect�assertIsNone)rrGrIrKs    r�test_AST_garbage_collectionz%AST_Tests.test_AST_garbage_collectionEs^��	�	�
�G�G�I���c���������k�k�!�#�#���
��������#�%� rc	���ttdfttdftt
dffD]�\}}}t
||�D]�\}}|jd|��5t|d|tj�}|jt|�|�|j|d�ddd�|jd||�	�5td|�ddd�����y#1swY�8xYw#1swY��xYw)
N�exec�single�eval�parsing)�action�input�?)rr�	compiling)rTrU�kind)r
rrrrr�zip�subTest�compiler�
PyCF_ONLY_ASTr,r
r+)rrU�outputrX�i�o�ast_trees       r�
test_snippetszAST_Tests.test_snippetsQs���
��v�.�
�>�8�4�
��v�.�$
��E�6�4�
�E�6�*���1��\�\��!�\�<�&�q�#�t�S�5F�5F�G�H��$�$�X�h�%7��;��)�)�(�F�;�=��\�\��A�D�\�I��H�c�4�0�J�I�+�$
�=�<��J�I�s�A
C�9C �C� C)c�~�ttztz}|D]$}tj|�}t|dd��&y)N�<string>rP)r
rrr�parser[)r�snippets_to_validate�snippet�trees    r�test_ast_validationzAST_Tests.test_ast_validation_s6��)�L�8�:�E��+�G��9�9�W�%�D��D�*�f�-�,rc���gd�}|D]�\}}|jd|�d|���5d}tj|�}||jd_||jd_|j
t�5t|dd�ddd�ddd���gd�}|D]�\}}|jd|�d|���5d}tj|�}||jd_	||jd_
|j
t�5t|dd�ddd�ddd���y#1swY��xYw#1swY��AxYw#1swY�-xYw#1swY��xYw)	N))�
�)i�������)rjrl)������)rmrkzCheck invalid linenos �:za = 1rrcrPzCheck invalid col_offset )rZrrd�bodyr&�
end_linenor:�
ValueErrorr[r'�end_col_offset)	r�invalid_linenosr&rqrfrg�invalid_col_offsetsr'rss	         r�!test_invalid_position_informationz+AST_Tests.test_invalid_position_informationfsE��M��"1��F�J���� 6�v�h�a�
�|�L�M�!���y�y��)��&,��	�	�!��#�*4��	�	�!��'��&�&�z�2��D�*�f�5�3�N�M�#2�R��*=�&�J�����+�J�<�q��8H�I��"���y�y��)��*4��	�	�!��'�.<��	�	�!��+��&�&�z�2��D�*�f�5�3���+>�	3�2��N�M��"3�2����sI�AD>�9D2�D>�<AE�E�E�2D;�7D>�>E	�E�E�E 	c
��tjtjtjddd��gdd��tjtjddd��gdd��gg��}t	|dd	�y)
N�builtinsrkr�rr&r')�namesr&r'�	traceback)rp�type_ignoresrcrP)r�Module�Import�aliasr[�rrgs  r�>test_compilation_of_ast_nodes_with_default_end_position_valueszHAST_Tests.test_compilation_of_ast_nodes_with_default_end_position_values~st���z�z��
�
��9�9�*�Q�1�M�N�� ��
�
�
��9�9�+�a�A�N�O�� ��
��
��"	��j�&�)rc��tjd�jdjj}|j|j�|j|j�|j|j�y)Nzx[::]r)	rrdrpr1�slicerM�upper�lower�step)r�slcs  r�
test_slicezAST_Tests.test_slice�s]���i�i�� �%�%�a�(�.�.�4�4�����#�)�)�$����#�)�)�$����#�(�(�#rc�~�tjd�jd}|j|j�y)Nzfrom . import yr)rrdrprM�module)r�ims  r�test_from_importzAST_Tests.test_from_import�s.��
�Y�Y�(�
)�
.�
.�q�
1�����"�)�)�$rc���tjd�}|j|jdtj�dj�|jd_t|dd�y)Nzfrom __future__ import divisionrz __future__ �<test>rP)rrd�assertIsInstancerp�
ImportFrom�stripr�r[)r�mods  r�!test_non_interned_future_from_astz+AST_Tests.test_non_interned_future_from_ast�sR���i�i�9�:�����c�h�h�q�k�3�>�>�:�+�1�1�3���������X�v�&rc��tjd�jd}|jt	|j
�d�|j
d}|j|jd�|j|j�|j|jd�|j|jd�|j|jd�|j|jd�tjd�jd}|j
d}|j|jd�|j|j�|j|jd�|j|jd�|j|jd�|j|jd�tjd	�jd}|j
d}|j|jd�|j|jd
�|j|jd�|j|jd�|j|jd�|j|jd�tjd�jd}|j
d}|j|jd
�|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�y)Nzfrom bar import yrrk�y��zfrom bar import *�*zfrom bar import y as z�z�zimport bar as foo�bar�foo�)
rrdrpr,�lenrzrrM�asnamer&rqr'rs)rr�rs   r�
test_aliaszAST_Tests.test_alias�s���
�Y�Y�*�
+�
0�
0��
3������R�X�X���*�������������S�)����%�,�,�'�������q�)�����)�)�1�-�����)�)�2�.�����-�-�r�2�
�Y�Y�*�
+�
0�
0��
3��������������S�)����%�,�,�'�������q�)�����)�)�1�-�����)�)�2�.�����-�-�r�2�
�Y�Y�/�
0�
5�
5�a�
8��������������S�)�������s�+�������q�)�����)�)�1�-�����)�)�2�.�����-�-�r�2�
�Y�Y�*�
+�
0�
0��
3��������������U�+�������u�-�������q�)�����)�)�1�-�����)�)�1�-�����-�-�r�2rc��|jttjtj��|jttj
tj��|jttjtj��|jttjtj��|jttjtj��|jttjtj��y�N)
�
assertTrue�
issubclassr�Forr$�Namer#r�
comprehension�Gt�rs r�test_base_classeszAST_Tests.test_base_classes�s������
�3�7�7�C�H�H�5�6����
�3�8�8�S�X�X�6�7����
�3�8�8�S�W�W�5�6����
�3�8�8�S�W�W�5�6����
�3�#4�#4�c�g�g�>�?����
�3�6�6�3�7�7�3�4rc��td�}d}dD]<}|jt|j|��5t	||�ddd��>y#1swY�IxYw)NrzSast\.{} is deprecated and will be removed in Python 3.14; use ast\.Constant instead��Num�Str�Bytes�NameConstant�Ellipsis)r�assertWarnsRegex�DeprecationWarning�formatr))rr�
depr_regexrs    r�test_import_deprecatedz AST_Tests.test_import_deprecated�sZ��!�%�(��
)�	�F�D��&�&�'9�:�;L�;L�T�;R�S���T�"�T�S�F�S�S�s�
A�A	c�2�tj�5tjddt�ddlm}m}m}m}m	}ddd�dD]�}tt|�}|j||�s�&|j|�5|jt�5|�}ddd�ddd�ttj�s��|j!t#|j$�t&���y#1swY��xYw#1swY�dxYw#1swY�hxYw)N�ignore�rr�)�warnings�catch_warnings�filterwarningsr�rr�r�r�r�r�r)rrZ�assertWarnsrr�assertIsrr"�tuple)	rr�r�r�r�r�r�itemr?s	         r�$test_field_attr_existence_deprecatedz.AST_Tests.test_field_attr_existence_deprecated�s���
�
$�
$�
&��#�#�H�b�2D�E�C�C�'�H�D��3��%�D�� � ��t�,��\�\�$�'��)�)�*<�=� �F��>�(��a����)��M�M�$�q�y�y�/�5�9�H�	'�
&��>�=��(�'�s/�*C5�D
�D�D
�5C>�D
�D
�
D	c�"�tjj�D]n\}}|dvr�|dk(r�|j||�s�$|�}t	|tj
�s�F|j
t|j�t��py)N>r�r�r�r�r��Index)
rr9�itemsrrrr�rr"r�)rrr�r?s    r�test_field_attr_existencez#AST_Tests.test_field_attr_existence�sn���,�,�,�,�.�J�D�$��J�J���w���� � ��t�,��F���a����)��M�M�$�q�y�y�/�5�9�/rc��tj�}|j|jd�|j	t
�5|jddd�|j|j�tjtdd��}|j|jd�|j|jd�y#1swY�yxYw)N)�posonlyargs�argsr<�
kwonlyargs�kw_defaults�kwarg�defaultsrk�r8�)
r�	argumentsr,r"r:r;r�rMr<�ranger>s  r�test_argumentszAST_Tests.test_arguments�s����M�M�O�����
�I�I�
�	
��
�
�~�
.�
�F�F�/����!�(�(�#��M�M�5��A�;�'���������#�������1�%�
/�
.�s�
C�Cc��tj�5tjddt�t	j
�}ddd�d_|j|jd�y#1swY�-xYw)Nr�r��)r�r�r�r�rr�r"r,r>s  r�#test_field_attr_writable_deprecatedz-AST_Tests.test_field_attr_writable_deprecatedsW��
�
$�
$�
&��#�#�H�b�2D�E����	�A�'���	�������C�(�'�
&�s�0A1�1A:c�r�tj�}d|_|j|jd�y)Nr�)r�Constantr"r,r>s  r�test_field_attr_writablez"AST_Tests.test_field_attr_writables(���L�L�N����	�������C�(rc	�F
�tj�5tjddt�ddlm}m}m}m}m	}ddd�tjd��5}tjddt�t	j
�}|j|jd�|jt�5|jddd�|jt�5|jddd�t	j
d	�}|j|jd	�|j|jd	�|jt�5|j ddd�|jt�5|j"ddd�t	j
d
��}|j|j d
�t	j
d	d��}|j|j d�|j|jd�|j|jd	�|j|jd	�|jt$tj
ddd
�|jt$tj
ddd
d��|jt	j
dd
��j&d
�|j)t$d�5t	j
dd
��ddd�|jt	j
d	�jd	�|jt	j
d�jd�|jt	j
d�jd�|jt	jd�j*d�|jt	jd�j*d�|j-t	jd�jd�|j-t	jd�jd�|j-t	jd�jd�ddd�|jD�cgc]}t/|j0���c}gd��y#1swY���xYw#1swY��xYw#1swY���xYw#1swY���xYw#1swY��dxYw#1swY��xYw#1swY��xYwcc}w)Nr�r�rr�T��record�always�r1rXr6r8�r&rkr��r�z(Num got multiple values for argument 'n'��n�@�@�42�42F)�Rast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead�OAttribute n is deprecated and will be removed in Python 3.14; use value insteadr�r�r�r�r�r�r�r�r�r�r�r�r�r��Rast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead�OAttribute s is deprecated and will be removed in Python 3.14; use value instead�Tast.Bytes is deprecated and will be removed in Python 3.14; use ast.Constant insteadr��[ast.NameConstant is deprecated and will be removed in Python 3.14; use ast.Constant insteadr�r�)r�r�r�r�rr�r�r�r�r�r,r"r:r;r1r�r&r7r=r��assertRaisesRegex�sr��str�message)	rr�r�r�r�r��wlogr?�ws	         r�test_classattrs_deprecatedz$AST_Tests.test_classattrs_deprecateds���
�
$�
$�
&��#�#�H�b�2D�E�C�C�'��
$�
$�D�
1�T��#�#�H�b�2D�E����	�A����Q�Y�Y�(9�:��"�"�>�2����3��"�"�>�2����3������A����Q�W�W�b�)����Q�S�S�"�%��"�"�>�2����3��"�"�>�2����3����q�!�A����Q�X�X�q�)�����1�%�A����Q�X�X�q�)����Q�Y�Y�(9�:����Q�W�W�b�)����Q�S�S�"�%����i����!�T�1�=����i����!�T�1�Q��G�
���S�W�W�Q�E�2�6�6��>��'�'��E������Q���

���S�W�W�R�[�]�]�B�/����S�W�W�T�]�_�_�d�3����S�W�W�U�^�-�-�u�5����S�W�W�T�]�_�_�d�3����S�Y�Y�u�-�/�/��7��M�M�#�*�*�4�0�6�6��=��M�M�#�*�*�5�1�7�7��?��M�M�#�*�*�4�0�6�6��=�a2�d	
���%)�*�T��S����^�T�*�
�	
�m'�
&��3�2��3�2��3�2��3�2��$���I2�
1��f
+s��*S�A!T�>
S�T�(
S�5A*T�
S+�,T�	
S8�ET�.T�FT�T�S�S	�T�S(	�#T�+S5	�0T�8T	�=T�T	�
T�Tc� �tj�}|j|jd�|j	t
�5|jddd�tjd�}|j|jd�|j	t
�5|jddd�|j	t
�5|jddd�tjd��}|j|jd�tjdd��}|j|jd�|j|jd�|j|jd�|j	ttjddd�|j	ttjdddd��|jtjdd��jd�|jtd	�5tjdd�
�ddd�|jtjd�jd�|jtjd�jd�|jtjd�jd�|jtjd
�jd
�|jtjd�jd�|jtjd�jd�|jtjd�jd�|jtjd�jd�|jtjd�jd�y#1swY���xYw#1swY��=xYw#1swY�� xYw#1swY���xYw)Nr�r6r8r�rrkr�r�z1Constant got multiple values for argument 'value'�r1r�r�r�r�TF.)
rr�r,r"r:r;r1r&r7r=r�r�r�r>s  r�test_classattrszAST_Tests.test_classattrsns����L�L�N��������$5�6�
�
�
�~�
.�
�G�G�/�
�L�L����������"�%�
�
�
�~�
.�
�H�H�/��
�
�~�
.�
�H�H�/�
�L�L��"��������1�%��L�L��A�&��������1�%�������$5�6�������"�%����)�S�\�\�1�d�A�>����)�S�\�\�1�d�A�a��H�	
������a�U�3�7�7��?�
�
#�
#��J�
�
�L�L��!�$�
�
	
������b�)�/�/��4�������d�+�1�1�4�8�������e�,�2�2�E�:�������d�+�1�1�4�8�������e�,�2�2�E�:��
�
�c�l�l�4�(�.�.��5��
�
�c�l�l�5�)�/�/��7��
�
�c�l�l�4�(�.�.��5��
�
�c�l�l�3�'�-�-�s�3�O/�
.��/�
.��/�
.��"
�
�s0�
O�!
O)�
O6�P�O&�)O3�6P�P
c���tj�5tjddt�ddlm}m}m}m}m	}ddd�tjd��5}tjddt�|jtt	j
d��tj�|jtt	j
d	��tj�|jtt	j
d
��tj�|jtt	jd��tj�|jtt	jd��tj�|jtt	jd��tj�|jtt	jd
��tj�|jtt	jd��tj�|jtt	j��tj�ddd�|jD�cgc]}t|j���c}gd��y#1swY���xYw#1swY�LxYwcc}w)Nr�r�rr�Tr�r�r6r�r�r�r�F)	r�r�r�r�r�r�r�r�zWast.Ellipsis is deprecated and will be removed in Python 3.14; use ast.Constant instead)r�r�r�r�rr�r�r�r�r�r�rr�r,r�r�)rr�r�r�r�r�r�r�s        r�
test_realtypezAST_Tests.test_realtype�s���
�
$�
$�
&��#�#�H�b�2D�E�C�C�'��
$�
$�D�
1�T��#�#�H�b�2D�E��M�M�$�s�w�w�r�{�+�S�\�\�:��M�M�$�s�w�w�t�}�-�s�|�|�<��M�M�$�s�w�w�u�~�.����=��M�M�$�s�w�w�t�}�-�s�|�|�<��M�M�$�s�y�y��/�0�#�,�,�?��M�M�$�s�/�/��5�6����E��M�M�$�s�/�/��6�7����F��M�M�$�s�/�/��5�6����E��M�M�$�s�|�|�~�.����=�2�	
���%)�*�T��S����^�T�*�

�
	
�!'�
&��2�
1��
+s�*K�H7K�+K+�K�K(c�t�ddlm}tj�5tjddt
�ddlm}m}m}m	}m
}ddd�d}t|jt
|jd��}t|jt
|jd��}	t|jt
|jd	��}
t|jt
|jd
��}t|jt
|jd��}dD]W}
|j|
�
�5|�5|
�}ddd�|�5|j�ddd�ddd��Y|	�5d�}ddd�|	�5|j�ddd�|
�5d�}ddd�|
�5|j�ddd�dD]W}
|j|
�
�5|�5|
�}ddd�|�5|j�ddd�ddd��Y|�5�}ddd�|�5|j�ddd�dD]E}
|j|
�
�5|�5|j||
��ddd�ddd��G|	�5|j|d��ddd�|
�5|j|d��ddd�dD]E}
|j|
�
�5|�5|j||
��ddd�ddd��G|�5|j|d��ddd�|	�5d�}ddd�||j �|
|j |�|�5|d�}ddd�|	|j �||j |�||j |�|�5|d�}ddd�|�5|j!||�ddd�|�5|d�}ddd�|�5|j!||�ddd�dD]E}
|j|
�
�5|�5|j!||
�|�ddd�ddd��G|	|j |d�|�|
|j |d�|�||j |d�|�||j |d�|�||j |�|�|	|j |�|�|
|j |�|�||j |�|�||j |�|�Gd�dt"�}|	�5|j||d��|�ddd�|�5|j!||d��|�ddd�y#1swY���xYw#1swY���xYw#1swY���xYw#1swY��CxYw#1swY���xYw#1swY���xYw#1swY���xYw#1swY���xYw#1swY���xYw#1swY��qxYw#1swY���xYw#1swY��jxYw#1swY��UxYw#1swY��"xYw#1swY��mxYw#1swY��
xYw#1swY���xYw#1swY���xYw#1swY��xYw#1swY���xYw#1swY���xYw#1swY��fxYw#1swY��xYw#1swY��
xYw#1swY���xYw#1swY���xYw#1swY���xYw#1swY��xYw#1swY���xYw#1swYyxYw)Nr)r�r�r�r�zQast.{} is deprecated and will be removed in Python 3.14; use ast.Constant insteadr�r�r�r�r�)r6g������@y������@)�argr�r��TFN.r6TF)r�TFc��eZdZy)�$AST_Tests.test_isinstance.<locals>.SNrDr5rr�Sr�/rHrr�)rr�r�r�r�r�r�r�r�r�r�rr�r�rZr��assertNotIsInstancer�)rr�r�r�r�r�r��cls_depr_msg�assertNumDeprecated�assertStrDeprecated�assertBytesDeprecated�assertNameConstantDeprecated�assertEllipsisDeprecatedr�r�r��b�er�s                   r�test_isinstancezAST_Tests.test_isinstance�sS�� �
�
$�
$�
&��#�#�H�b�2D�E�C�C�'�

'�	�
&��!�!�#5�|�7J�7J�5�7Q�
��&��!�!�#5�|�7J�7J�5�7Q�
��!(��!�!�#5�|�7J�7J�7�7S�!
��(/��!�!������/�(
�$�
$+��!�!�#5�|�7J�7J�:�7V�$
� �!�C����#��&�(�*��C��A�+�(�*��)�)�!�S�1�+�'�&�!�!�
"��D�	�A�#�
 �
"��!�!�!�S�)�#�#�
$��e��A�%�
"�
$��!�!�!�U�+�%�%�C����#��&�1�3�$�S�)�A�4�1�3��)�)�!�\�:�4�'�&�%�&�
'��
�A�(�
%�
'��!�!�!�X�.�(�!�C����#��&�(�*��)�)�(�3�-��=�+�'�&�!�
!�
"��!�!�(�4�.�#�6�#�#�
$��!�!�(�5�/�5�9�%�%�C����#��&�1�3��)�)�(�3�-��F�4�'�&�%�
&�
'��!�!�(�3�-��:�(�!�
"��D�	�A�#��D�4�4�a��=��d�6�6��5�A�
 �
"��B��A�#��D�4�4�a��=�$�T�%=�%=�q�,�O� ��!9�!9�1�h�G�
)�
+��T�"�A�,�
 �
"��$�$�Q��,�#�*�
+��U�#�A�,�
 �
"��$�$�Q��,�#�%�C����#��&�(�*��,�,�X�c�]�C�@�+�'�&�%�
	�D�4�4�h�r�l�C�H��d�6�6�����N�$��$�$�h�r�l�L�	
�	!��!9�!9�8�B�<��R��D�4�4�h�j�#�F��D�4�4�h�j�#�F��d�6�6��
�E�J�$�T�%=�%=�x�z�<�X� ��!9�!9�8�:�x�P�	��	�!�
"��!�!�(�1�T�7�"3�S�9�#�
 �
"��$�$�X�a��g�%6��<�#�
"�m'�
&��:+�*��*�*��'�&��#�
"��
"�
"��%�
$��
$�
$��
4�3��3�3��'�&��(�
'��
'�
'��
+�*��'�&��#�
"��%�
$��
4�3��'�&��(�
'��#�
"��
#�
"��,�
+��
"�
"��,�
+��
"�
"��
+�*��'�&��&#�
"��
"�
"�s��*X5�8Y�	Y�	Y�Y�+Y�	Y)�Y6�>	Z�Z�Z7�	Z�Z7�(Z*�;Z7�[�+[�[+�%[�>[+�[8�?\�7\�?\�\�1\,�	\9�	]�-	]�] �'	]-�?]:�1^�9^�^�^!�
^.�5X?�Y�Y�Y�Y�Y&	�)Y3�6Z�Z
�Z�Z'�"Z7�*Z4�/Z7�7[	�[�[�[(�#[+�+[5	�8\�\�\�\�\)	�,\6�9]�]�]� ]*�-]7�:^�^�^�^	�!^+�.^7c��tj�5tjddt�ddlm}ddd�tjd��5}tjddt�Gd�d	tj
�}Gd
�dtj
�}|d�}|j
|jd�|j
|jd
�|jt|�|�|j||�|j|tj
�|j||�|jt	j
d�|�|d��}|j
|jd�|jt|�|�ddd�|j
D�cgc]}t|j���c}gd��y#1swY���xYw#1swY�LxYwcc}w)Nr�r�r�r�Tr�r�c���eZdZ�fd�Z�xZS)�8AST_Tests.test_constant_subclasses_deprecated.<locals>.Nc�2��t�|�|i|��d|_y�N�spam��super�__init__r��rr��kwargs�	__class__s   �rrzAAST_Tests.test_constant_subclasses_deprecated.<locals>.N.__init__@s����G�$�d�5�f�5�#�D�Fr�rErrFr�
__classcell__�rs@r�Nr
?s
���$�$rrc��eZdZy)�9AST_Tests.test_constant_subclasses_deprecated.<locals>.N2NrDr5rr�N2rD���rrr6r
r�)r�r�r�r�r�r�)r�r�r�r�rr�r,r�r�r�rr�r�r�r�)rr�r�rrr�r�s       r�#test_constant_subclasses_deprecatedz-AST_Tests.test_constant_subclasses_deprecated7sx��
�
$�
$�
&��#�#�H�b�2D�E��'��
$�
$�D�
1�T��#�#�H�b�2D�E�
$�C�G�G�
$�

�S�W�W�
��"��A����Q�S�S�"�%����Q�S�S�&�)��M�M�$�q�'�1�%��!�!�!�Q�'��!�!�!�S�W�W�-��$�$�Q��+��$�$�S�W�W�R�[�!�4��B��A����Q�S�S�"�%��M�M�$�q�'�1�%�+2�.	
���%)�*�T��S����^�T�*�
�
	
�7'�
&��2�
1��0
+s�"G%�EG2�>G>�%G/�2G;c��Gd�dtj�}Gd�dtj�}|d�}|j|jd�|j|jd�|jt|�|�|j
t||��|j
t|tj��|jt||��|jttjd�|��|d��}|j|jd�|jt|�|�y)Nc���eZdZ�fd�Z�xZS)�-AST_Tests.test_constant_subclasses.<locals>.Nc�2��t�|�|i|��d|_yrrrs   �rrz6AST_Tests.test_constant_subclasses.<locals>.N.__init__as����� �$�1�&�1���rrrs@rrr`s
���
 �
 rrc��eZdZy)�.AST_Tests.test_constant_subclasses.<locals>.N2NrDr5rrrr"erHrrr6r
r�)	rr�r,r1r�rr�r�assertFalse)rrrr�s    r�test_constant_subclassesz"AST_Tests.test_constant_subclasses_s���	 ����	 �
	����	�
�b�E��������"�%�������f�%�����a��!�$����
�1�a�(�)����
�1�c�l�l�3�4�����A�r�*�+�����C�L�L��$4�a�8�9�
�B�K��������"�%�����a��!�$rc��tjd�g}tj|g�}|j|j|�y)Nr6)rr�r}r,rp)rrpr?s   r�test_modulezAST_Tests.test_modulets7�����R� �!���J�J�t�R� ���������&rc	��tj�}|j|jd�d|_|j|jd�tj
d�}tj
d�}tj�}tj|||�}|j|j|�|j|j|�|j|j|�tjddd�}|j|jd�|j|jd�|j|jd�tjdddd��}|j|jd�|j|jd�|j|jd�|j|jd�|jttjdddd�|jttjddddd��tjdddd�	�}|j|jd�|j|jd�|j|jd�|j|jd�tjdddd
��}|j|jd
�y)N)�left�op�right�rkr�r8rr��)r(r)r*r&r6)�	foobarbaz)
r�BinOpr,r"r-r��Addr(r)r*r&r:r=)rr?�n1�n3�addops     r�test_nodeclasseszAST_Tests.test_nodeclassesys3���I�I�K��������$;�<����������a�(�
�\�\�!�_��
�\�\�!�_�����	���I�I�b�%��$���������$�������u�%�������"�%��I�I�a��A����������#�������q�!�������!�$��I�I�a��A�a�(���������#�������q�!�������!�$�������1�%�	
���)�S�Y�Y��1�a��;����)�S�Y�Y��1�a��1��E�
�I�I�1��!�A�6���������#�������q�!�������!�$�������1�%�
�I�I�a��A��,��������b�)rc�d�tj�}|j|jd�y)Nr5)r�Subr,r"r>s  r�test_no_fieldszAST_Tests.test_no_fields�s!���G�G�I��������B�'rc���ddl}t|jdz�D]Y}d�tD�D]G}|j	|j||��}|j
t|�t|���I�[y)Nrrkc3�8K�|]}t|ddd����y�w)rVrPiN)r[)�.0r^s  r�	<genexpr>z*AST_Tests.test_pickling.<locals>.<genexpr>�s����K�
�1���3���6�
�s�)�pickler��HIGHEST_PROTOCOLr
�loads�dumpsr,r
)rr;�protocolr�ast2s     r�
test_picklingzAST_Tests.test_pickling�s`����f�5�5��9�:�H�K�
�K���|�|�F�L�L��h�$?�@��� � ��$���#��?�L�;rc	�R�tdd��}tjtjtjdi|��fi|��gg�}|jt�5}t|dd�ddd�|jdtj��y#1swY�/xYw)Nr8r��r&r'r�rPzbut got <ast.exprr5)�dictrr}�Exprr#r:r=r[�assertInr��	exception)r�pos�m�cms    r�test_invalid_sumzAST_Tests.test_invalid_sum�s{���!��*���J�J��������C��8�C�8�9�2�>��
�
�
�y�
)�R��A�x��(�*��
�
�)�3�r�|�|�+<�=�*�
)�s�!B�B&c	��tjtjtjdtj���gg�}tj
|�|j
t�5}t|dd�ddd�|jdtj��y#1swY�/xYw)Nr6r�rPzidentifier must be of type str)rr}rEr��Load�fix_missing_locationsr:r=r[rFr�rG)rrIrJs   r�test_invalid_identifierz!AST_Tests.test_invalid_identifier�s���J�J�������"�c�h�h�j�!9�:�;�R�@���!�!�!�$�
�
�
�y�
)�R��A�x��(�*��
�
�6��B�L�L�8I�J�*�
)�s�;B7�7Cc�:�tddtftddtf�fD]l}tjtj|���}tj
|�|j
td�5t|dd�ddd��ny#1swY�yxYw)Nrkr8�rpzinvalid type in Constant: typer�rR)	�int�	frozensetr�
Expressionr�rNr�r=r[)r�invalid_constantrs   r�test_invalid_constantzAST_Tests.test_invalid_constant�s|�� #�a��C�[�)�Q��3�K�2H� H�����C�L�L�1A�$B�C�A��%�%�a�(��'�'�	�3S�T���8�V�,�U�T�!I�U�T�s�8B�B	c�<�tjd�}d|jdjdj_|j	t
�5}t
|dd�ddd�|jdtj��y#1swY�/xYw)Nzdef f():
 yield from g()rr�rPzfield 'value' is required)
rrdrpr1r:rrr[rFr�rG)r�empty_yield_fromrJs   r�test_empty_yield_fromzAST_Tests.test_empty_yield_from�sz���9�9�%@�A��7;����a� �%�%�a�(�.�.�4�
�
�
�z�
*�b��$�h��7�+��
�
�1�3�r�|�|�3D�E�+�
*�s�B�Bc��ddl}d�}tj|d|�5|jtt
jd�ddd�y#1swYyxYw)Nrc��yr�r5�r�s r�
bad_normalizez0AST_Tests.test_issue31592.<locals>.bad_normalize�s��r�	normalizeuϕ)�unicodedatar�	swap_attrr:r=rrd)rr_r]s   r�test_issue31592zAST_Tests.test_issue31592�sC��	�	��
�
�{�K��
G����i����H�=�H�
G�
G�s�&A�Ac��tjd�}|jdj}|j}|j}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�tjd�}|jdj}|j}|j}|j|jd�|j|jd�|j|jd�|j|jd	�|j|jd�|j|jd�|j|jd	�|j|jd	�|j|jd�|j|jd�|j|jd�|j|jd�y)
Nz4+5+6+7rr�r+r�z
4+5-\
 6-7rkr,r8)
rrdrpr1r(r,r'rsr&rq)rrg�parent_binop�child_binop�grandchild_binops     r� test_issue18374_binop_col_offsetz*AST_Tests.test_issue18374_binop_col_offset�s���y�y��#���y�y��|�)�)��"�'�'��&�+�+������0�0�!�4�����4�4�a�8�����/�/��3�����3�3�Q�7����)�4�4�a�8����)�8�8�!�<��y�y��(���y�y��|�)�)��"�'�'��&�+�+������0�0�!�4�����,�,�a�0�����4�4�a�8�����0�0�!�4�����/�/��3�����+�+�Q�/�����3�3�Q�7�����/�/��3����)�4�4�a�8����)�0�0�!�4����)�8�8�!�<����)�4�4�a�8rc��tjd�}|jdjdj}|j|jd�y)Nz@a.b.c
def f(): passrr,)rrdrpr!r1r,rs)rrg�attr_bs   r�*test_issue39579_dotted_name_end_col_offsetz4AST_Tests.test_issue39579_dotted_name_end_col_offset�sE���y�y�0�1�����1��,�,�Q�/�5�5������.�.��2rc��|jtjjd�|jtjjd�|jtj
jd�|jtjjd�tjj�D�cgc]}d|j����}}dtjj�dj��|d<|jtjjjd�|�ycc}w)	Nz0withitem(expr context_expr, expr? optional_vars)�GtEz%Name(identifier id, expr_context ctx)zBcmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotInz     | zexpr = r�
)r,r�withitem�__doc__rkr��cmpopr#�__subclasses__�assertCountEqual�split)rr�expressionss   r�test_ast_asdl_signaturez!AST_Tests.test_ast_asdl_signature�s�������L�L� � �"T�	
�	
��������%�0�������)�)�+R�S�����I�I���P�	
�=@�H�H�<S�<S�<U�V�<U�D������/�<U��V�"�3�8�8�#:�#:�#<�Q�#?�#G�#G�"H�I��A�����c�h�h�.�.�4�4�T�:�K�H��Ws�	Ec���tjdd��tjdd��|jt�5tjdd��ddd�|jt�5tjdd��ddd�tjdd��tjdd��|jt�5tjdd��ddd�|jt�5tjdd��ddd�y#1swY��xYw#1swY��xYw#1swY�WxYw#1swYyxYw)Nzdef foo(x, /): ...�r�r���feature_versionzdef bar(x=1, /): ...�r�r�zlambda x, /: ...zlambda x=1, /: ...�rrdr:�SyntaxErrorr�s r�$test_positional_only_feature_versionz.AST_Tests.test_positional_only_feature_version
s����	�	�&��?��	�	�(�&�A�
�
�
�{�
+��I�I�*�F�C�,�
�
�
�{�
+��I�I�,�f�E�,�	�	�	�$�f�=��	�	�&��?�
�
�
�{�
+��I�I�(�&�A�,�
�
�
�{�
+��I�I�*�F�C�,�
+�,�
+��
+�
+��
,�
+��
+�
+�s0�D2�9D>�E
�E�2D;�>E�
E�Ec��tjdd��|jt�5tjdd��ddd�y#1swYyxYw)Nz(x := 0)rvrwryrzr�s r�*test_assignment_expression_feature_versionz4AST_Tests.test_assignment_expression_feature_versions8���	�	�*�f�5�
�
�
�{�
+��I�I�j�&�9�,�
+�
+�s�A�Ac�2�tjdd��y)Nzwith (x() if y else z()): ...rvrw)rrdr�s r�@test_conditional_context_managers_parse_with_low_feature_versionzJAST_Tests.test_conditional_context_managers_parse_with_low_feature_version!s���	�	�1�6�Jrc���td�}tj|�|jt�5tj|d��ddd�y#1swYyxYw)Nz9
        try: ...
        except* Exception: ...
        )r�rjrw)rrrdr:r{)r�codes  r�%test_exception_groups_feature_versionz/AST_Tests.test_exception_groups_feature_version%sF����
��	�	�	�$��
�
�
�{�
+��I�I�d�G�4�,�
+�
+�s�A�A c��gd�}|D]f}|j|�5tj|�|jt�5tj|d��ddd�ddd��hy#1swY�xYw#1swY�xYw)N)ztype X = intzclass X[T]: passzdef f[T](): pass)r��rw)rZrrdr:r{)r�samples�samples   r� test_type_params_feature_versionz*AST_Tests.test_type_params_feature_version.sh��
��
�F����f�%��	�	�&�!��&�&�{�3��I�I�f�g�>�4�&�%��4�3��&�%�s#�+A=�A1�A=�1A:�6A=�=B	c��|jt�5tjdd��ddd�|jt�5tjdd��ddd�y#1swY�?xYw#1swYyxYw)N�pass)r8r�rw)r,r)r:rrrrdr�s r�"test_invalid_major_feature_versionz,AST_Tests.test_invalid_major_feature_version:sW��
�
�
�z�
*��I�I�f�f�5�+�
�
�
�z�
*��I�I�f�f�5�+�
*�+�
*��
*�
*�s�A,�A8�,A5�8Bc�*�dD]�}tjtj|tj���}tj|�|jtd|�d��5t|dd�ddd���y#1swY��xYw)N)�True�False�Nonez"identifier field can't represent 'z
' constantr�rR)rrTr�rMrNr�rrr[)r�constantr#s   r�test_constant_as_namezAST_Tests.test_constant_as_name@sy��/�H��>�>�#�(�(�8�S�X�X�Z�"@�A�D��%�%�d�+��'�'��@��
�*�U����h��/���0���s�0B	�	B	c�~�Gd�dtj�}tj|tj�y)Nc�~�eZdZdZej
�Zej
�Zej
�Zej
�Z	ej
�Z
ej
�Zej
�Zej
�Z
ej
�ZeZej
�Zej
�Zej
�Zej
�Zej
�Zej
�Zej
�Zej
�Zej
�Zd�Zy)�3AST_Tests.test_precedence_enum.<locals>._Precedencez5Precedence table that originated from python grammar.c�N�	|j|dz�S#t$r|cYSwxYw)Nrk)rrrr�s r�nextz8AST_Tests.test_precedence_enum.<locals>._Precedence.nextbs.�� ��>�>�$��(�3�3��!� ��K� �s��$�$N)rErrFrn�enum�auto�
NAMED_EXPR�TUPLE�YIELD�TEST�OR�AND�NOT�CMP�EXPR�BOR�BXOR�BAND�SHIFT�ARITH�TERM�FACTOR�POWER�AWAIT�ATOMr�r5rr�_Precedencer�Js���G�"�����J��D�I�I�K�E��D�I�I�K�E��4�9�9�;�D������B��$�)�)�+�C��$�)�)�+�C��$�)�)�+�C��4�9�9�;�D��C��4�9�9�;�D��4�9�9�;�D��D�I�I�K�E��D�I�I�K�E��4�9�9�;�D��T�Y�Y�[�F��D�I�I�K�E��D�I�I�K�E��4�9�9�;�D�
 rr�)r��IntEnum�_test_simple_enumrr�)rr�s  r�test_precedence_enumzAST_Tests.test_precedence_enumIs(��	 �$�,�,�	 �<	
���{�C�O�O�<rzexhausts limited stack on WASIc�������tjdz�d�ttjdz������fd�}|dd�|dd�|dd�|dd	�y)
Nrki��g�������?c�\��||�	zz}tj|���fD]o}|||zz}dj|||�}�jt|��5tj�5tj|�ddd�ddd��qy#1swY�xYw#1swY��xYw)NzCompiling ({!r} + {!r} * {})��msg)rrdr�r:�RecursionErrorr�infinite_recursion)
�prefix�repeated�	expect_ok�depth�broken�details�crash_depth�
fail_depthr�
success_depths
      ����r�check_limitz7AST_Tests.test_ast_recursion_limit.<locals>.check_limitqs������M�!9�9�I��I�I�i� �$�k�2���(�U�"2�2��8�?�?���RW�X���&�&�~�7�&�C� �3�3�5��	�	�&�)�6�D�C�3�6�5��D�C�s$�B"�-B�B"�B�B"�"B+	rI�()z.bz[0]z*a)r�C_RECURSION_LIMITrR)rr�r�r�r�s` @@@r�test_ast_recursion_limitz"AST_Tests.test_ast_recursion_limitjs^����.�.��2�
����G�5�5��;�<�
�	*�	�C����C����C����C��rc��|jtd��5tjd�ddd�y#1swYyxYw)Nz,source code string cannot contain null bytesr�zab)r:r{rrdr�s r�test_null_byteszAST_Tests.test_null_bytes�s9��
�
�
��K��
�
�I�I�f��
�
�
�s	�7�Ar�attr�source�returnc���|j|j�d|���5tj|�}d}tj|�D]!}t||�s�t
||d�|dz
}�#|j|d�tjd|�d|j���}|jtd|�d��5t|dd	�ddd�ddd�y#1swY�xYw#1swYyxYw)
N�.rrkzfield 'z' is required for �^�$r�rP)
rZrErrd�walkr�setattrr,�re�escaper�rrr[)rrr�r�rg�foundr3rs        r�assert_none_checkzAST_Tests.assert_none_check�s���
�\�\�T�]�]�O�1�T�F�3�
4��9�9�V�$�D��E����$����e�T�*��E�4��.��Q�J�E�(�
���U�A�&��	�	�G�D�6�);�D�M�M�?�K�L�A��'�'�
�a��s�!�H�=���h��/�>�5�
4�>�=��5�
4�s*�<C.�A%C.�C"�C.�"C+	�'C.�.C7c	�@�tjddftjddftjddftjddftjd	d
ftj
ddftjd
dfg}|D]\}}}|j|||��y)Nrzimport spam as SPAMr�zdef spam(SPAM): spam�targetz[spam for SPAM in spam]�iterz[spam for spam in SPAM]r1zspam(**SPAM)�patternzmatch spam:
 case SPAM: spam�context_exprzwith SPAM: spam)rrr�r��keyword�
match_casermr�)r�testsrr�r�s     r�test_none_checkszAST_Tests.test_none_checks�s���
�Y�Y�� 5�6�
�W�W�e�3�4�
�
�
��*C�D�
�
�
��(A�B�
�[�[�'�>�2�
�^�^�Y�(G�H�
�\�\�>�+<�=�
��#(��D�$���"�"�4��v�6�#(r)r�N)>rErrF�maxDiffrr+r@rNrarhrvr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr$r&r3r6rArKrOrVrYr�cpython_onlyrarfrirtr|r~r�r�r�r�r�r��unittest�skipIf�is_wasir�r�rrrr�r�r�r5rrrrsw���G�3�D�&�
!�1�.�6�0*�($�%�'�$3�L5�#�:�:�&�.)�)�R
�h+4�Z
�@z=�x&
�P%�*'�
**�X(�
@�>�K�-�F�
���	>��	>�9�>3�
I�
D�:�
K�5�
?�6�0�=�B�X�_�_�W�_�_�&F�G������H��(�0�d�3�7�7�m�0�3�0��0�PT�0�7rrc��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�Zy)�ASTHelpers_TestNc���tjd�}tdddtj�}|j	tj
|�tj
|��y)Nz
foo(1 + 1)z	<unknown>rP)rrdr[r\r,�dump)rrIrs   r�
test_parsezASTHelpers_Test.test_parse�sF���I�I�l�#���L�+�v�s�7H�7H�I��������!��c�h�h�q�k�2rc��	ddzy#t$rh|jt�5}tjd�ddd�n#1swYnxYw|jjj�YywxYw)Nrkrz'\U')�	Exceptionr:r{r�literal_eval�assertIsNotNonerG�__context__�rrs  r�test_parse_in_errorz#ASTHelpers_Test.test_parse_in_error�s_��	:�
��E���	:��"�"�;�/�1�� � ��)�0�/�/��� � ����!8�!8�9�	:�s%��A9�A�	A9�A	�
,A9�8A9c��tjd�}|jtj|�d�|jtj|d��d�|jtj|d��d�y)	N�spam(eggs, "and cheese")z�Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), args=[Name(id='eggs', ctx=Load()), Constant(value='and cheese')], keywords=[]))], type_ignores=[])F��annotate_fieldszbModule([Expr(Call(Name('spam', Load()), [Name('eggs', Load()), Constant('and cheese')], []))], [])T��include_attributesa�Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=4), args=[Name(id='eggs', ctx=Load(), lineno=1, col_offset=5, end_lineno=1, end_col_offset=9), Constant(value='and cheese', lineno=1, col_offset=11, end_lineno=1, end_col_offset=23)], keywords=[], lineno=1, col_offset=0, end_lineno=1, end_col_offset=24), lineno=1, col_offset=0, end_lineno=1, end_col_offset=24)], type_ignores=[])�rrdr,r��rrs  r�	test_dumpzASTHelpers_Test.test_dump�sv���y�y�3�4������H�H�T�N�
/�	
�	
����H�H�T�5�1�
2�	
�
	
����H�H�T�d�3�
Z�		
rc��tjd�}|jtj|d��d�|jtj|dd��d�|jtj|d	d�
�d�y)Nr�r���indentz�Module(
   body=[
      Expr(
         value=Call(
            func=Name(id='spam', ctx=Load()),
            args=[
               Name(id='eggs', ctx=Load()),
               Constant(value='and cheese')],
            keywords=[]))],
   type_ignores=[])F�	)r�r�z�Module(
	[
		Expr(
			Call(
				Name('spam', Load()),
				[
					Name('eggs', Load()),
					Constant('and cheese')],
				[]))],
	[])T)r�r�a�Module(
   body=[
      Expr(
         value=Call(
            func=Name(
               id='spam',
               ctx=Load(),
               lineno=1,
               col_offset=0,
               end_lineno=1,
               end_col_offset=4),
            args=[
               Name(
                  id='eggs',
                  ctx=Load(),
                  lineno=1,
                  col_offset=5,
                  end_lineno=1,
                  end_col_offset=9),
               Constant(
                  value='and cheese',
                  lineno=1,
                  col_offset=11,
                  end_lineno=1,
                  end_col_offset=23)],
            keywords=[],
            lineno=1,
            col_offset=0,
            end_lineno=1,
            end_col_offset=24),
         lineno=1,
         col_offset=0,
         end_lineno=1,
         end_col_offset=24)],
   type_ignores=[])r�r�s  r�test_dump_indentz ASTHelpers_Test.test_dump_indent�s|���y�y�3�4������H�H�T�!�$�

�
	
�	
����H�H�T�5��>�

	�
	
�	
����H�H�T�d�1�=�#
�&	
rc��tjdd��}|jtj|�d�|jtj|d��d�tjtjdtj
��	�dd�
�}|jtj|�d�|jtj|d�
�d�|jtj|d��d�|jtj|dd��d�tjtjdtj
��	���}|jtj|�d�|jtj|d�
�d�y)Nr�r,rCzRaise()Tr�zRaise(lineno=3, col_offset=4)r)�id�ctx)�excr&r'z#Raise(exc=Name(id='e', ctx=Load()))Fr�zRaise(Name('e', Load()))z;Raise(exc=Name(id='e', ctx=Load()), lineno=3, col_offset=4))r�r�z0Raise(Name('e', Load()), lineno=3, col_offset=4))�causez%Raise(cause=Name(id='e', ctx=Load()))zRaise(cause=Name('e', Load())))r�Raiser,r�r�rMr�s  r�test_dump_incompletez$ASTHelpers_Test.test_dump_incompletesD���y�y��a�0��������$���3�����H�H�T�d�3�5T�	
��y�y�S�X�X��#�(�(�*�=�a�TU�V��������$��)N�O�����H�H�T�5�1�3M�	
�	
����H�H�T�d�3�I�	
�	
����H�H�T�5�T�J�>�	
��y�y�s�x�x�3�C�H�H�J�?�@��������$��)P�Q�����H�H�T�5�1�3S�	
rc�|�tjdd��}tjtjd�|jj
�|j_|j
tj|d��d�tjdddd�	�}tj|tjdd�
��}|j|j�|j|j�|j
|jd�|j
|jd�y)N�1 + 1rR��moder8Tr�z�Expression(body=BinOp(left=Constant(value=1, lineno=1, col_offset=0, end_lineno=1, end_col_offset=1), op=Add(), right=Constant(value=2, lineno=1, col_offset=4, end_lineno=1, end_col_offset=5), lineno=1, col_offset=0, end_lineno=1, end_col_offset=5))rk)r'r&rqrs)r'r&)rrd�
copy_locationr�rpr*r,r��CallrMrqrsr&r')r�src�news   r�test_copy_locationz"ASTHelpers_Test.test_copy_location(s����i�i��f�-���*�*�3�<�<��?�C�H�H�N�N�K���������H�H�S�T�2�
=�	
��h�h�!�A�!�A�N������S�X�X��d�%K�L�����#�.�.�)����#�,�,�-�������Q�'��������+rc���tjd�}|jjtjtj
tjdtj��tjd�gg���|j|tj|��d|_|jtj|d��d�y)Nz
write("spam")r
�eggsTr�a�Module(body=[Expr(value=Call(func=Name(id='write', ctx=Load(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=5), args=[Constant(value='spam', lineno=1, col_offset=6, end_lineno=1, end_col_offset=12)], keywords=[], lineno=1, col_offset=0, end_lineno=1, end_col_offset=13), lineno=1, col_offset=0, end_lineno=1, end_col_offset=13), Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, col_offset=0, end_lineno=1, end_col_offset=0), args=[Constant(value='eggs', lineno=1, col_offset=0, end_lineno=1, end_col_offset=0)], keywords=[], lineno=1, col_offset=0, end_lineno=1, end_col_offset=0), lineno=1, col_offset=0, end_lineno=1, end_col_offset=0)], type_ignores=[]))
rrdrp�appendrErr�rMr�r,rNr�r��rrs  r�test_fix_missing_locationsz*ASTHelpers_Test.test_fix_missing_locations9s����i�i��(��������H�H�S�X�X�c�h�h�v�s�x�x�z�:�S�\�\�&�=Q�<R�TV�W�X�	
�	
����c�7�7��<�=��������H�H�S�T�2�

�
	
rc��tjdd��}|jtj|d��|�|jtj|d��d�tjdd��}|jtj|j
d��|j
�|jtj|d��d�tjtjd	tj��ggd
��}|jtj|�jd�|jtj|�j�y)
NrrRrr�r�Tr�z�Expression(body=BinOp(left=Constant(value=1, lineno=4, col_offset=0, end_lineno=4, end_col_offset=1), op=Add(), right=Constant(value=1, lineno=4, col_offset=4, end_lineno=4, end_col_offset=5), lineno=4, col_offset=0, end_lineno=4, end_col_offset=5))�testrk)�funcr��keywordsr&r8)rrdr,�increment_linenor�rprr�rMr&rMrqr
s  r�test_increment_linenoz%ASTHelpers_Test.test_increment_linenoOs���i�i��f�-������-�-�c�Q�7��=�����H�H�S�T�2�
=�	
��i�i��f�-������-�-�c�h�h�!�<�c�h�h�G�����H�H�S�T�2�
=�	
��h�h����&�#�(�(�*�-�B��A�
��	
����-�-�c�2�9�9�1�=����#�.�.�s�3�>�>�?rc�h�tjtd�d��}tj|d��|j	|j
djd�|j	|j
djd	�|j	|j
djd
�y)Nzb        a = 1
        b = 2 # type: ignore
        c = 3
        d = 4 # type: ignore@tag
        T)�
type_commentsr+r�rr�rk�	z@tag)rrdrrr,r|r&�tagr
s  r�test_increment_lineno_on_modulez/ASTHelpers_Test.test_increment_lineno_on_moduleis����i�i���

��
��	���S�A�&�����)�)�!�,�3�3�Q�7�����)�)�!�,�3�3�Q�7�����)�)�!�,�0�0�&�9rc��tjdd��}ttj|j��}|j|j
d�jd�|j|ggd��y)N�foo()rRrrr�)rr�)rrdrD�iter_fieldsrpr,�popr�)rr�ds   r�test_iter_fieldsz ASTHelpers_Test.test_iter_fieldsxs\���y�y��v�.���������+�,��������v��)�)�5�1������R�8�9rc	�,�tjdd��}|jtt	tj
|j���d�tj
|j�}|jt|�jd�|jt|�jd�|jt|�jd�|jtjt|��d�y)	Nzspam(23, 42, eggs='leek')rRrr,r
�r6z1keyword(arg='eggs', value=Constant(value='leek')))rrdr,r�r*�iter_child_nodesrpr�r�r1r�)rr�iterators   r�test_iter_child_nodesz%ASTHelpers_Test.test_iter_child_nodes~s����y�y�4�6�B������T�#�"6�"6�t�y�y�"A�B�C�Q�G��'�'��	�	�2������h��*�*�F�3�����h��-�-�r�2�����h��-�-�r�2�����H�H�T�(�^�$�?�	
rc�B�tjd�}|jtj|�d�tjd�}|jtj|jd�d�tjd�}|jtj|jd�d�tjd�}|jtj|jd�d�tjd�}|jtj|jdd�	�d
�tjd�}|jttj|jd�y)Nz"""line one
  line two"""zline one
line twoz&class foo:
  """line one
  line two"""rz&def foo():
  """line one
  line two"""z#async def foo():
  """spam
  ham"""zspam
hamF)�cleanz
spam
  hamr?)rrdr,�
get_docstringrpr:r=r�s  r�test_get_docstringz"ASTHelpers_Test.test_get_docstring�s&���y�y�5�6������*�*�4�0�2F�G��y�y�C�D������*�*�4�9�9�Q�<�8�:N�O��y�y�C�D������*�*�4�9�9�Q�<�8�:N�O��y�y�@�A������*�*�4�9�9�Q�<�8�+�F��y�y�@�A������*�*�4�9�9�Q�<�u�E�}�U��y�y��~�����)�S�%6�%6��	�	�!��Erc��|jtjtjd���tjd�}|jtj|��tjd�}|jtj|��tjd�}|jtj|jd��tjd�}|jtj|jd��tjd�}|jtj|jd��tjd�}|jtj|jd��tjd�}|jtj|jd��tjd	�}|jtj|jd��tjd
�}|jtj|jd��tjd�}|jtj|jd��y)Nr�zx = "not docstring"zdef foo():
  passzclass foo:
  passrz class foo:
  x = "not docstring"z class foo:
  def bar(self): passz def foo():
  x = "not docstring"zasync def foo():
  passz&async def foo():
  x = "not docstring"zasync def foo():
  42)rMrr'rdrpr�s  r�test_get_docstring_nonez'ASTHelpers_Test.test_get_docstring_none�s������#�+�+�C�I�I�b�M�:�;��y�y�.�/�����#�+�+�D�1�2��y�y�-�.�����#�+�+�D�1�2��y�y�-�.�����#�+�+�D�I�I�a�L�9�:��y�y�<�=�����#�+�+�D�I�I�a�L�9�:��y�y�<�=�����#�+�+�D�I�I�a�L�9�:��y�y�-�.�����#�+�+�D�I�I�a�L�9�:��y�y�<�=�����#�+�+�D�I�I�a�L�9�:��y�y�3�4�����#�+�+�D�I�I�a�L�9�:��y�y�B�C�����#�+�+�D�I�I�a�L�9�:��y�y�1�2�����#�+�+�D�I�I�a�L�9�:rc�2�tjd�}|j|jdjd�|j|jdj
d�|j|jdjdjd�|j|jdjdj
d�|j|jdjdjdjd�|j|jdjdjdj
d�|j|jdjdjd�|j|jdjdj
d�|j|jdjd�|j|jdj
d	�y)
Nz�"""line one
line two"""

def foo():
  """line one
  line two"""

  def bar():
    """line one
    line two"""
  """line one
  line two"""
"""line one
line two"""

rrkr8r+r,rr��
)rrdr,rpr'r&r�s  r�:test_multi_line_docstring_col_offset_and_lineno_issue16806zJASTHelpers_Test.test_multi_line_docstring_col_offset_and_lineno_issue16806�s����y�y�
+�
��	
������1��0�0�!�4�������1��,�,�a�0�������1��*�*�1�-�8�8�!�<�������1��*�*�1�-�4�4�a�8�������1��*�*�1�-�2�2�1�5�@�@�!�D�������1��*�*�1�-�2�2�1�5�<�<�a�@�������1��*�*�1�-�8�8�!�<�������1��*�*�1�-�4�4�b�9�������1��0�0�!�4�������1��,�,�b�1rc���tjd�}|jdjd}|j	|j
d�|j	|jd�y)Nz if a:
    pass
elif b:
    pass
rr��rrdrp�orelser,r&r'�rr�	elif_stmts   r�test_elif_stmt_start_positionz-ASTHelpers_Test.test_elif_stmt_start_position�sU���y�y�?�@���I�I�a�L�'�'��*�	�����)�)�1�-�����-�-�q�1rc���tjd�}|jdjd}|j	|j
d�|j	|jd�y)Nz/if a:
    pass
elif b:
    pass
else:
    pass
rr�r/r1s   r�'test_elif_stmt_start_position_with_elsez7ASTHelpers_Test.test_elif_stmt_start_position_with_else�sU���y�y�P�Q���I�I�a�L�'�'��*�	�����)�)�1�-�����-�-�q�1rc���tjd�}|jdjjd}|j|jd�|j|jd�y)Nz
f(*[0, 1])rrkr)rrdrpr1r�r,rqrs)rr�starred_exprs   r�*test_starred_expr_end_position_within_callz:ASTHelpers_Test.test_starred_expr_end_position_within_call�sZ���y�y��&���y�y��|�)�)�.�.�q�1������0�0�!�4�����4�4�a�8rc��|jtjd�gd��|jtjd�ddi�|jtjd�d�|jtjd�hd	��|jtjd
�d�|jtjd�t��|j	t
tjd
�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jt
tjd��d�|j	t
tjd�|j	t
tjd�|j	t
tjd�y)Nz	[1, 2, 3]�rkr8r�z{"foo": 42}r�r6z(True, False, None)r�z	{1, 2, 3}>rkr8r�zb"hi"shizset()r�6�z+6z-6i����z3.25g
@z+3.25z-3.25g
�z-0.0z++6z+Truez2+3)r,rr��setr:rr�reprr�s r�test_literal_evalz!ASTHelpers_Test.test_literal_eval�s�������)�)�+�6�	�B�����)�)�-�8�5�"�+�F�����)�)�*?�@�BU�V�����)�)�+�6�	�B�����)�)�'�2�E�:�����)�)�'�2�C�E�:����*�c�&6�&6��@�����)�)�#�.��2�����)�)�$�/��3�����)�)�$�/��4�����)�)�&�1�4�8�����)�)�'�2�D�9�����)�)�'�2�E�:�����c�.�.�v�6�7��@����*�c�&6�&6��>����*�c�&6�&6��@����*�c�&6�&6��>rc��tjd�5tjd�|j	t
�5}tjd�ddd�|j
dtj��|j
dt|j��ddd�y#1swY�\xYw#1swYyxYw)Ni���3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333��33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333zExceeds the limit z Consider hexadecimal )	r�adjust_int_max_str_digitsrr�r:r{rFr�rG)r�err_ctxs  r�test_literal_eval_str_int_limitz/ASTHelpers_Test.test_literal_eval_str_int_limit�s���
�
.�
.�t�
4����Z�(��"�"�;�/�7�� � ��,�0��M�M�.��G�4E�4E�0F�G��M�M�2�C��8I�8I�4J�K�5�
4�/�/��5�
4�s$�+B>�B2�AB>�2B;	�7B>�>Cc�8�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd	�d
�|jtjd�d�|jtjd
�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d
�|jttjd�|jttjd�|jttjd�|jttjd�|jttjd�y)N�6jy@z-6jy��z6.75jy@z-6.75jy��z3+6jy@@z-3+6jy�@z3-6jy@�z-3-6jy��z
3.25+6.75jy
@@z-3.25+6.75jy
�@z
3.25-6.75jy
@�z-3.25-6.75jy
��z(3+6j)z-6j+3z-6j+3jz3+-6jz3+(0+6j)z-(3+6j))r,rr�r:rrr�s r�test_literal_eval_complexz)ASTHelpers_Test.test_literal_eval_complex�s�������)�)�$�/��4�����)�)�%�0�#�6�����)�)�'�2�E�:�����)�)�(�3�V�<�����)�)�&�1�6�:�����)�)�'�2�G�<�����)�)�&�1�6�:�����)�)�'�2�G�<�����)�)�,�7��F�����)�)�-�8�-�H�����)�)�,�7��F�����)�)�-�8�-�H�����)�)�(�3�V�<����*�c�&6�&6��@����*�c�&6�&6��A����*�c�&6�&6��@����*�c�&6�&6�
�C����*�c�&6�&6�	�Brc���tjtjd�tjd�gtjd�g��}|jttj
|�tjtjd�gtjd�tjd�g��}|jttj
|�y)Nrkr8r�)�keys�values)r�Dictr�r:rrr�)r�	malformeds  r�&test_literal_eval_malformed_dict_nodesz6ASTHelpers_Test.test_literal_eval_malformed_dict_nodes
s����H�H��,�,�q�/�3�<�<��?�3�S�\�\�!�_�<M�
�	�	
���*�c�&6�&6�	�B��H�H��,�,�q�/�"�C�L�L��O�S�\�\�!�_�+M�
�	�	
���*�c�&6�&6�	�Brc�,�|jtjd�d�|jtjd�d�|jtjd�d�|jttjd�y)Nz    -1���z		-1z 	 -1z
 -1)r,rr�r:�IndentationErrorr�s r�test_literal_eval_trailing_wsz-ASTHelpers_Test.test_literal_eval_trailing_wssl������)�)�(�3�R�8�����)�)�(�3�R�8�����)�)�(�3�R�8����*�C�,<�,<�g�Frc	��d}|jt|�5tjd�ddd�tjtj
�tjtj
�tjd���}|jt|dd��d}|jt|�5tj|�ddd�y#1swY��xYw#1swYyxYw)Nz#malformed node or string on line 3:z{'a': 1,
'b':2,
'c':++3,
'd':4}r<r&zmalformed node or string:)	r�rrrr��UnaryOp�UAddr�rMr))rr�rs   r�"test_literal_eval_malformed_linenoz2ASTHelpers_Test.test_literal_eval_malformed_linenos���4��
�
#�
#�J��
4����A�B�5��{�{�3�8�8�:�s�{�{�3�8�8�:�s�|�|�A��'O�P�����'�$��$�7�8�*��
�
#�
#�J��
4����T�"�5�
4�
5�
4��5�
4�s�C+�C7�+C4�7Dc��|jtd�5tjd�ddd�y#1swYyxYw)Nzunexpected indentz4
                \
                (\
            \ )r�r{rr�r�s r�test_literal_eval_syntax_errorsz/ASTHelpers_Test.test_literal_eval_syntax_errors(s3��
�
#�
#�K�1D�
E�����
�F�
E�
E�s�6�?c�H�tjdtjd��gddd��g}tj|g�}|j	t
�5}t
|dd�ddd�|jdtj��y#1swY�/xYw)N�time�sleep�r�r�rz�levelr&r'rrPzinvalid integer value: None)
rr�rr}r:rrr[rFr�rG)rrpr�rJs    r�test_bad_integerz ASTHelpers_Test.test_bad_integer/s���
�N�N���y�y�g�.�/����
�
���j�j��r�"��
�
�
�z�
*�b��C���(�+��
�
�3�S����5F�G�+�
*�s�B�B!c���tjdtjddd��gddd��g}tj|g�}t	|dd�}i}t||�|j
d|�y)NrZr[rryr]rrP)rr�rr}r[rPrF)rrpr�r��nss     r�test_level_as_nonez"ASTHelpers_Test.test_level_as_none?sp���N�N���y�y�g�a�A�F�G����
�
���j�j��r�"���s�F�F�+��
���T�2���
�
�g�r�"rc�L�tjtj�dd��}||_|j	t
�5t
j�5ttj|�dd�ddd�ddd�y#1swY�xYw#1swYyxYw�Nr)r)r&r'r�rR�
rrT�Not�operandr:r�rr�r[rTr�s  r�test_recursion_directz%ASTHelpers_Test.test_recursion_directOsm���K�K�3�7�7�9�Q�1�=����	�
�
�
�~�
.��+�+�-�����q�)�8�V�<�.�/�
.�-�-��/�
.�s$�B�!B�=B�B	�B�B#c��tjtj�dd��}tjtj�dd��}||_||_|j	t
�5t
j�5ttj|�dd�ddd�ddd�y#1swY�xYw#1swYyxYwrdre)rr�fs   r�test_recursion_indirectz'ASTHelpers_Test.test_recursion_indirectVs����K�K�3�7�7�9�Q�1�=���K�K�3�7�7�9�Q�1�=����	���	�
�
�
�~�
.��+�+�-�����q�)�8�V�<�.�/�
.�-�-��/�
.�s$�8C�
!B?�.C�?C	�C�C) rErrFr�r�r�r�r�rr	rrrrr$r(r*r-r3r5r8r?rErHrNrRrVrXr_rbrhrkr5rrr�r��s����G�3�
:�
�0D
�L
�2,�"
�,@�4
:�:�

�F�&;�62�&2�2�9�?�&L�C�*C�G�	#��H� #� =�=rr�c�
�eZdZdGed�d�ZdHed�d�ZdHd�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#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/�Z0d0�Z1d1�Z2e3jhd2�d3��Z5e6jnd4�Z8e6jre8�Z:e6jnd5�Z;e6jre;�Z<e6jnd6�Z=e6j|d6�Z?e6j�d7e6j���ZBe6jre6j�e6j�e6j�d5e6j���d8e6j���d9e6j����e6jre6j�e6j�e6j�d5e6j���d8e6j���d9e6j����e6jre6jnd:��e6jre6jnd6��e6jre6jnd;��e6j|d<�e6j�e6j|d<�g�e6j�e6j�e6j|d<�g�g�e6j�e8e=ge<g�e6j�e=e8ge<e:gd=�>�e6j�e=e6j�e6j�d?e6j���e6j���ge<e:gd@�>�e6j�e6j�e6j�e;d8e6j���d9e6j���ggg�A�e6j�eBgd=ge:g�A�e6j�eBgge:g�A�e6j�eBe6j|d<�ggg�A�e6j�eBe6j��ggg�A�e6j�eBgge6j��g�A�e6j�e=gd=ge:g�A�e6j�e6j�d=�g�e6j�dB�C�e6j�g�e6j�e:g�e6j�e:e<e6j|dD�g�e6j�dE�C�e6j�d5�C�e6j�e6j�dE�g�e6j�ggdE�>�gZLdF�ZMy)I�ASTValidatorTestsN�r�c��dx|_|_tj|�|�t	|d|�y|j|�5}t	|d|�ddd�|j
|tj��y#1swY�/xYw)Nrr�)	r&r'rrNr[r:rFr�rG)rr�r�rr�rJs      rr�zASTValidatorTests.modasp��&'�'��
�S�^��!�!�#�&��;��C��4�(��"�"�3�'�2���X�t�,�(��M�M�#�s�2�<�<�0�1�(�'�s�B�B
c��tjtj|�gg�}|j|||��y)Nrn)rr}rEr�)rrr�r�r�s     rr#zASTValidatorTests.exprks/���j�j�#�(�(�4�.�)�2�.������c�s��#rc�V�tj|gg�}|j||�yr�)rr}r�)rr$r�r�s    rr$zASTValidatorTests.stmtos"���j�j�$���$������c�rc	�d�tjtjtjdtj���g�}|j|dd�tjtjdtj���}|j|dd�y)Nr?�must have Load contextrQrR)r�InteractiverEr��Storer�rT)rrIs  rr&zASTValidatorTests.test_modulessn���O�O�S�X�X�c�h�h�s�C�I�I�K�&@�A�B�C������,�h�7��N�N�3�8�8�C�����5�6������,�f�5rc����							d�fd�	}tjdtjdtj���g}|||��d�|||��d�|||��d�||tjd�g��d	�||tjd
�g��d�tjdtjdtj
���g}|||tjdtj��g�
�d�tjdtjdtj
���tjdtjdtj
���g}|||dtjdtj��g��d�y)Nc	�r��|�g}|�g}|�g}|�g}|�g}tj|||||||�}�|�Sr�)rr�)r�r�r<r�r�r�r��facs       �rr�z5ASTValidatorTests._check_arguments.<locals>.argumentszsd����|����"� ���!��
������"� ���=�=��k�6�:�{�E�8��D��t�9�rr?r\rs)r�)r�r�)r�z"more positional defaults than argsr,)r�z3length of kwonlyargs is not the same as kw_defaults)r�r�rIrr�)r�r�)NNNNNNN)rr�r�rur�rM)rrx�checkr�r�s `   r�_check_argumentsz"ASTValidatorTests._check_argumentsyst����������	�0����S�X�X�c�3�9�9�;�7�8�9��
�i�T�"�$<�=�
�i�D�)�+C�D�
�i�4�(�*B�C�
�����Q��0�1�3W�	
�	��3�<�<��?�"3�4�A�	
�����S�X�X�c�3�8�8�:�6�7�8��
��4�3�8�8�C�����+E�*F�G�$�	
�

�G�G�C����#�s�x�x�z�2�3��G�G�C����#�s�x�x�z�2�3�
��	���D�#�(�(�3��	�	��:T�3U�V�$�	
rc��tjggdggdg�}tjd|ggddg�}|j|d�tjd|tj�gtj
dtj��gddg�}|j|d�tjd|tj�ggtj
dtj��dg�}|j|d�tjdtj�tj�g�}|j|�d�}|j||j�y)Nr?zempty body on FunctionDefrsc	�^�tjd|tj�ggddg�S�Nr?)r�FunctionDef�Passr\s rrxz+ASTValidatorTests.test_funcdef.<locals>.fac�s%���?�?�3��s�x�x�z�l�B��d�B�O�Or)rr�r~r$rr�rurz)rrIrjrxs    r�test_funcdefzASTValidatorTests.test_funcdef�s���M�M�"�b�$��B��b�9���O�O�C��B��D�$��;���	�	�!�0�1��O�O���S�X�X�Z�L�3�8�8�C�����#=�">��d�B�
��	
�	�	�!�-�.��O�O���S�X�X�Z�L�"�c�h�h�s�C�I�I�K�&@�$��
��	
�	�	�!�-�.��O�O�C�����3�8�8�:�,�?���	�	�!��	P�	
���c�4�9�9�-rc���d�}d}tjtj|��}|jd}|j|tj�|j||��y)Nc��|tjd�x��\dk(r�tjd�x��\ r�dk(r�\tjd�x��\dk(r� r�dk(r~\tjd�x�i\ rfdk(ra\tj
d�x�L\dk(rFtjd�x�3\tj
d�x�\dk(rtjd�x�\y	y	)
Nr5r�r\rkr��capybara�pacaranaTF)rr~r�r�rr�rM)rs r�matcherz@ASTValidatorTests.test_funcdef_pattern_matching.<locals>.matcher�sx����_�_����M�M�8�'7�'7������ �L�S�X�X�Z�6�6�S�X�X�5�j�#�(�(�*��H�H�4�Z�������� rzZ
            @capybara
            def foo(bar) -> pacarana:
                pass
        r)rrd�textwraprrpr�r~r�)rr�r�r��funcdefs     r�test_funcdef_pattern_matchingz/ASTValidatorTests.test_funcdef_pattern_matching�sY��	!���
���8�?�?�4�0�1���+�+�a�.�����g�s���7������(�)rc��	d
d�}|j|tjdtj��g��d�|j|tjdtjdtj���g��d�|j|g��d�|j|dg��d�|j|tjdtj��g�	�d�y)Nc��|�g}|�g}|�tj�g}|�g}|�g}tjd|||||�S)N�myclass)rr�ClassDef)�basesrrpr!�type_paramss     r�clsz,ASTValidatorTests.test_classdef.<locals>.cls�s_���}��������|����
�|���%�!#���"� ���<�<��5�(�D�.�+��
rr?)r�rs)rrQzempty body on ClassDef�None disallowed)r!)NNNNN)r$rr�rur�)rr�s  r�
test_classdefzASTValidatorTests.test_classdef�s���SW�	�"	
�	�	�#�S�X�X�c�3�9�9�;�7�8�9�;S�T��	�	��#�+�+�c�3�8�8�C�����+E�F�G�H�$�	
�	
�	�	�#�2�,� 8�9��	�	�#�D�6�"�$5�6��	�	������c�i�i�k� :�;�<�>V�	
rc	�2�|jtjg�d�|jtjdg�d�|jtjtjdtj��g�d�y)Nzempty targets on Deleter�r?zmust have Del context)r$r�Deleter�rMr�s r�test_deletezASTValidatorTests.test_delete�s_���	�	�#�*�*�R�.�";�<��	�	�#�*�*�d�V�$�&7�8��	�	�#�*�*�c�h�h�s�C�H�H�J�7�8�9�;R�Src
��|jtjgtjd��d�|jtjdgtjd��d�|jtjtjdtj
��gtjd��d�|jtjtjdtj��gtjdtj���d�y)Nr�zempty targets on Assignr�r?�must have Store contextr�rs)r$r�Assignr�r�rMrur�s r�test_assignzASTValidatorTests.test_assign�s����	�	�#�*�*�R����a��1�3L�M��	�	�#�*�*�d�V�S�\�\�!�_�5�7H�I��	�	��J�J�����c�h�h�j�1�2�C�L�L��O�D�%�	
�	
�	�	��J�J�����c�i�i�k�2�3�S�X�X�c�3�9�9�;�5O�P�$�	
rc	� �tjtjdtj��tj�tjdtj���}|j|d�tjtjdtj��tj�tjdtj���}|j|d�y)Nr?r�r�rs)r�	AugAssignr�rMr/r$ru)r�augs  r�test_augassignz ASTValidatorTests.test_augassigns����m�m��H�H�S�#�(�(�*�%�s�w�w�y�#�(�(�3����
�2K�
��	
�	�	�#�0�1��m�m��H�H�S�#�)�)�+�&����	�3�8�8�C�����3M�
��	
�	�	�#�/�0rc
�t�tjdtj��}tjdtj��}tj�}|jtj||gg�d�|jtjtjdtj��||gg�d�|jtj|tjdtj��|gg�d�tjtjdtj���}|jtj|||gg�d�|jtj|||g|g�d�y)Nr?r�zempty body on Forr�rs)rr�rurMrr$r�rE)rr?r��prs     r�test_forzASTValidatorTests.test_fors$���H�H�S�#�)�)�+�&���H�H�S�#�(�(�*�%���H�H�J���	�	�#�'�'�!�Q��B�'�)<�=��	�	��G�G�C�H�H�S�#�(�(�*�-�q�1�#�r�:�<U�	
�	
�	�	��G�G�A�s�x�x��S�Y�Y�[�1�A�3��;�=U�	
�
�H�H�S�X�X�c�3�9�9�;�/�0���	�	�#�'�'�!�Q���R�(�*B�C��	�	�#�'�'�!�Q���a�S�)�+C�Drc
�F�|jtjtjd�gg�d�|jtjtjdtj
��tj�gg�d�|jtjtjd�tj�gtjtjdtj
���g�d�y)Nr�zempty body on Whiler?rs)r$r�Whiler�r�rurrEr�s r�
test_whilezASTValidatorTests.test_whiles����	�	�#�)�)�C�L�L��O�R��4�6K�L��	�	��I�I�c�h�h�s�C�I�I�K�0�3�8�8�:�,��C�$�	
�	
�	�	��I�I����Q��#�(�(�*��������#�s�y�y�{�9S�0T�/U�
�
%�		
rc�:�|jtjtjd�gg�d�tjtjdtj
��tj�gg�}|j|d�tjtjd�tjtjdtj
���gg�}|j|d�tjtjd�tj�gtjtjdtj
���g�}|j|d�y)Nr�zempty body on Ifr?rs)r$r�Ifr�r�rurrE)rr^s  r�test_ifzASTValidatorTests.test_if,s����	�	�#�&�&����a��"�b�1�3E�F��F�F�3�8�8�C�����-����
�|�R�@���	�	�!�-�.��F�F�3�<�<��?�S�X�X�c�h�h�s�C�I�I�K�.H�%I�$J�B�O���	�	�!�-�.��F�F��L�L��O�c�h�h�j�\�C�H�H�S�X�X�c�3�9�9�;�5O�,P�+Q�
��	
�	�	�!�-�.rc���tj�}|jtjg|g�d�tjtj
d�d�}|jtj|gg�d�tjtjdtj��d�}|jtj|g|g�d�tjtj
d�tjdtj���}|jtj|g|g�d�y)Nzempty items on Withr�zempty body on Withr?rsr�)	rrr$�Withrmr�r�rurM)rr�r^s   r�	test_withzASTValidatorTests.test_with7s����H�H�J���	�	�#�(�(�2��s�#�%:�;��L�L����a��$�/���	�	�#�(�(�A�3��#�%9�:��L�L����#�s�y�y�{�3�T�:���	�	�#�(�(�A�3���$�&>�?��L�L����a��#�(�(�3����
�*C�D���	�	�#�(�(�A�3���$�&?�@rc���tjdtjd��}|j|d�tjtjdtj
��d�}|j|d�tjtjd�tjdtj
���}|j|d�y)Nr�z!Raise with cause but no exceptionr?rsr,)rr�r�r$r�ru)r�rs  r�
test_raisezASTValidatorTests.test_raiseAs����I�I�d�C�L�L��O�,���	�	�!�8�9��I�I�c�h�h�s�C�I�I�K�0�$�7���	�	�!�-�.��I�I�c�l�l�1�o�s�x�x��S�Y�Y�[�'A�B���	�	�!�-�.rc��tj�}tjggg|g�}|j|d�tjtjtj
dtj���ggg|g�}|j|d�tj|gggg�}|j|d�tj|gg|g|g�}|j|d�tj|gtjddg�ggg�}|j|d�tjtj
dtj��d|g�g}|jtj|g|gg�d�tjdd|g�g}tj|g|tjtj
dtj���g|g�}|j|d�tj|g||gtjtj
dtj���g�}|j|d�y)Nzempty body on Tryr?rsz-Try has neither except handlers nor finalbodyz%Try has orelse but no except handlers�empty body on ExceptHandlerr�)rr�Tryr$rEr�ru�
ExceptHandler�rr��trs    r�test_tryzASTValidatorTests.test_tryIs����H�H�J���G�G�B��B���$���	�	�!�(�)��G�G�S�X�X�c�h�h�s�C�I�I�K�8�9�:�B��Q�C�H���	�	�!�-�.��G�G�Q�C��R��$���	�	�!�D�E��G�G�Q�C��a�S�1�#�&���	�	�!�<�=��G�G�Q�C�#�+�+�D�#�r�:�;�R��D���	�	�!�2�3�
�
�
�s�x�x��S�Y�Y�[�9�3���
D�E���	�	�#�'�'�1�#�q�"�b�)�+C�D�
�
�
�t�S�1�#�
.�/���G�G�Q�C��S�X�X�c�h�h�s�C�I�I�K�&@�A�B�Q�C�H���	�	�!�-�.��G�G�Q�C��Q�C�#�(�(�3�8�8�C�����+E�"F�!G�H���	�	�!�-�.rc��tj�}tjggg|g�}|j|d�tjtjtj
dtj���ggg|g�}|j|d�tj|gggg�}|j|d�tj|gg|g|g�}|j|d�tj|gtjddg�ggg�}|j|d�tjtj
dtj��d|g�g}|jtj|g|gg�d�tjdd|g�g}tj|g|tjtj
dtj���g|g�}|j|d�tj|g||gtjtj
dtj���g�}|j|d�y)Nzempty body on TryStarr?rsz1TryStar has neither except handlers nor finalbodyz)TryStar has orelse but no except handlersr�r�)rr�TryStarr$rEr�rur�r�s    r�
test_try_starzASTValidatorTests.test_try_star]s����H�H�J���K�K��B��Q�C�(���	�	�!�,�-��K�K����#�(�(�3��	�	��"<�=�>��B���L���	�	�!�-�.��K�K���R��R�(���	�	�!�H�I��K�K���R�!��q�c�*���	�	�!�@�A��K�K���c�/�/��c�2�>�?��R�H���	�	�!�2�3�
�
�
�s�x�x��S�Y�Y�[�9�3���
D�E���	�	�#�+�+�q�c�1�b�"�-�/G�H�
�
�
�t�S�1�#�
.�/���K�K���Q����#�(�(�3��	�	��*D�!E� F���L���	�	�!�-�.��K�K���Q���c�h�h�s�x�x��S�Y�Y�[�/I�&J�%K�L���	�	�!�-�.rc	��|jtjtjdtj��d�d�tjtjdtj
��tjdtj���}|j|d�y)Nr?rsr�)r$r�Assertr�rurM)r�assrts  r�test_assertzASTValidatorTests.test_assertqss���	�	��J�J�s�x�x��S�Y�Y�[�1�4�8�:R�	
��
�
�3�8�8�C�����4�c�h�h�s�C�I�I�K�6P�Q���	�	�%�1�2rc�N�|jtjg�d�y)Nzempty names on Import)r$rr~r�s r�test_importzASTValidatorTests.test_importx����	�	�#�*�*�R�.�"9�:rc���tjdtjdd�gd�}|j|d�|jtjdgd�d�y)Nr?i���zNegative ImportFrom levelrzempty names on ImportFrom)rr�rr$)r�imps  r�test_importfromz!ASTValidatorTests.test_importfrom{sM���n�n�T�C�I�I�c�4�$8�#9�3�?���	�	�#�2�3��	�	�#�.�.��r�1�-�/J�Krc�N�|jtjg�d�y)Nzempty names on Global)r$r�Globalr�s r�test_globalzASTValidatorTests.test_global�r�rc�N�|jtjg�d�y)Nzempty names on Nonlocal)r$r�Nonlocalr�s r�
test_nonlocalzASTValidatorTests.test_nonlocal�s���	�	�#�,�,�r�"�$=�>rc��tjtjdtj���}|j	|d�y�Nr?rs)rrEr�rur$r�s  r�	test_exprzASTValidatorTests.test_expr�s0���H�H�S�X�X�c�3�9�9�;�/�0���	�	�!�-�.rc	��tjtj�g�}|j|d�tjtj�tjd�g�}|j|d�tjtj�tjd�dg�}|j|d�tjtj�tjd�tj
dtj��g�}|j|d�y)Nzless than 2 valuesr�r,r�r?rs)r�BoolOp�Andr#r�r�ru)rrs  r�test_boolopzASTValidatorTests.test_boolop�s����J�J�s�w�w�y�"�%���	�	�!�)�*��J�J�s�w�w�y�3�<�<��?�"3�4���	�	�!�)�*��J�J�s�w�w�y�3�<�<��?�D�"9�:���	�	�!�&�'��J�J�s�w�w�y�3�<�<��?�C�H�H�S�#�)�)�+�4N�"O�P���	�	�!�-�.rc���tjtj�tjdtj���}|j|d�yr�)rrTrfr�rur#)r�us  r�test_unaryopzASTValidatorTests.test_unaryop�s8���K�K����	�3�8�8�C�����#=�>���	�	�!�-�.rc
��tjggdggdg�}|jtj|tjdtj
���d�d�}|j
||j�y)Nr?rsc�z�tj|tjdtj���Sr})r�Lambdar�rMr\s rrxz*ASTValidatorTests.test_lambda.<locals>.fac�s$���:�:�d�C�H�H�S�#�(�(�*�$=�>�>r)rr�r#r�r�rurz)rrIrxs   r�test_lambdazASTValidatorTests.test_lambda�sb���M�M�"�b�$��B��b�9���	�	�#�*�*�Q�����c�i�i�k� :�;�=U�V�	?�	
���c�4�9�9�-rc��tjdtj��}tjdtj��}|||f|||f|||ffD]$}|j	tj
|�d��&y�Nr?r�rs)rr�rMrur#�IfExp)r�lr�r�s    r�
test_ifexpzASTValidatorTests.test_ifexp�si���H�H�S�#�(�(�*�%���H�H�S�#�)�)�+�&����1�I��1�a�y�1�a��)�3�D��I�I�c�i�i��&�(@�A�4rc�B�tjgtjdtj��g�}|j	|d�tjtjdtj��gdg�}|j	|d�y)Nr?zsame number of keys as valuesr�)rrLr�rMr#)rrs  r�	test_dictzASTValidatorTests.test_dict�sj���H�H�R�#�(�(�3����
�3�4�5���	�	�!�4�5��H�H�c�h�h�s�C�H�H�J�/�0�4�&�9���	�	�!�&�'rc���|jtjdg�d�tjtjdtj��g�}|j|d�y�Nr�r?rs)r#r�Setr�ru�rr�s  r�test_setzASTValidatorTests.test_set�sL���	�	�#�'�'�4�&�/�#4�5��G�G�S�X�X�c�3�9�9�;�/�0�1���	�	�!�-�.rc	���|j|g�d�tjtjdtj��tjdtj��gd�}|j||g�d�tjtjdtj
��tjdtj
��gd�}|j||g�d�tjdtj
��}tjdtj��}tj||dgd�}|j||g�d�tj||tjdtj
��gd�}|j||g�d�y)Nz comprehension with no generatorsr?rr�rsr�r�)r#rr�r�rMru)rrx�gr?r�s     r�_check_comprehensionz&ASTValidatorTests._check_comprehension�sQ���	�	�#�b�'�=�>�����H�H�S�#�(�(�*�%�s�x�x��S�X�X�Z�'@�"�a�
��	
�	�	�#�q�c�(�5�6�����H�H�S�#�)�)�+�&�����c�i�i�k�(B�B��
��	
�	�	�#�q�c�(�4�5��H�H�S�#�)�)�+�&���H�H�S�#�(�(�*�%�����a��T�F�A�.���	�	�#�q�c�(�-�.����a��S�X�X�c�3�9�9�;�%?�$@�!�D���	�	�#�q�c�(�4�5rc	�z��tjtjdtj��tjdtj��gd�}|j�tjdtj��|g�d��fd�}|j
|�y)Nr?rrsc�b���tjdtj��|�Sr})rr�ru)�gensrxs �r�wrapz,ASTValidatorTests._simple_comp.<locals>.wrap�s!����s�x�x��S�Y�Y�[�1�4�8�8r)rr�r�rurMr#r�)rrxr�r�s `  r�_simple_compzASTValidatorTests._simple_comp�s~�������H�H�S�#�)�)�+�&�����c�h�h�j�(A�2�q�
��	
�	�	�#�c�h�h�s�C�I�I�K�0�1�#�6�8P�Q�	9�	
�!�!�$�'rc�B�|jtj�yr�)r�r�ListCompr�s r�
test_listcompzASTValidatorTests.test_listcomp�s�����#�,�,�'rc�B�|jtj�yr�)r�r�SetCompr�s r�test_setcompzASTValidatorTests.test_setcomp�s�����#�+�+�&rc�B�|jtj�yr�)r�r�GeneratorExpr�s r�test_generatorexpz#ASTValidatorTests.test_generatorexp�s�����#�*�*�+rc���tjtjdtj��tjdtj��gd�}tj
tjdtj��tjdtj��|g�}|j
|d�tj
tjdtj��tjdtj��|g�}|j
|d�d�}|j|�y)Nr�r�rr?rsc���tjdtj��}tjdtj��}tj|||�S)Nr?r�)rr�rM�DictComp)�comps�k�vs   r�factoryz0ASTValidatorTests.test_dictcomp.<locals>.factory�sA������c�h�h�j�)�A�����c�h�h�j�)�A��<�<��1�e�,�,r)rr�r�rurMr�r#r�)rr��cr�s    r�
test_dictcompzASTValidatorTests.test_dictcomp�s�������H�H�S�#�)�)�+�&�����c�h�h�j�(A�2�q�
��
�L�L����#�s�y�y�{�3�S�X�X�c�3�8�8�:�5N�QR�PS�T���	�	�!�-�.��L�L����#�s�x�x�z�2�C�H�H�S�#�)�)�+�4N�QR�PS�T���	�	�!�-�.�	-�
	
�!�!�'�*rc	�0�|jtjtjdtj���d�|jtj
tjdtj���d�y)Nr?zmust have Load)r#r�Yieldr�ru�	YieldFromr�s r�
test_yieldzASTValidatorTests.test_yield�sT���	�	�#�)�)�C�H�H�S�#�)�)�+�6�7�9I�J��	�	�#�-�-�����c�i�i�k� :�;�=M�Nrc���tjdtj��}tj|tj�gg�}|j|d�tj|tj�gtjd�tjd�g�}|j|d�tjtjd�tj�g|g�}|j|�tj|tj�gtjd�g�}|j|�y)Nr?zno comparatorsr,r+z,different number of comparators and operands�blah)rr�rM�Compare�Inr#r�)rr(�comps   r�test_comparezASTValidatorTests.test_compare�s����x�x��S�X�X�Z�(���{�{�4�#�&�&�(��R�0���	�	�$�(�)��{�{�4�#�&�&�(��c�l�l�1�o�s�|�|�A��-O�P���	�	�$�F�G��{�{�3�<�<��/�#�&�&�(��d�V�D���	�	�$���{�{�4�#�&�&�(��c�l�l�6�.B�-C�D���	�	�$�rc���tjdtj��}tjdtj��g}tjdtjdtj���g}tjtjdtj
��||�}|j
|d�tj|dg|�}|j
|d�tjdtjdtj
���g}tj|||�}|j
|d�y)Nr?r�r�r�rsr�)rr�rMr�rrur#)rrr�r�call�bad_keywordss      r�	test_callzASTValidatorTests.test_call�s����x�x��S�X�X�Z�(������c�h�h�j�)�*���K�K��S�X�X�c�3�8�8�:�%>�?�@���x�x�����c�i�i�k�2�D�(�C���	�	�$�0�1��x�x��t�f�h�/���	�	�$�)�*����C����#�s�y�y�{�)C�D�E���x�x��d�L�1���	�	�$�0�1rc���tjd��5}tjddt�ddlm}ddd�tjd��5}tjddt�Gd�d	t�}Gd
�dt�}Gd�d
t�}dD]&}|jt	j
|���(|�|�|�fD]-}|jt	j
|�dt���/	ddd�|jD�cgc]}t|j���c}gd��y#1swY��xYw#1swY�LxYwcc}w)NTr�r�r�rrr�c��eZdZy)�*ASTValidatorTests.test_num.<locals>.subintNrDr5rr�subintr

rrrc��eZdZy)�,ASTValidatorTests.test_num.<locals>.subfloatNrDr5rr�subfloatr

rrrc��eZdZy)�.ASTValidatorTests.test_num.<locals>.subcomplexNrDr5rr�
subcomplexrrrr)�0�hellozinvalid typern)r�r�r�r�r�)r�r�r�r�rr�rR�float�complexr#r=r,r�r�)rr�r�rrr�objr�s        r�test_numzASTValidatorTests.test_nums��
�
$�
$�D�
1�T��#�#�H�b�2D�E��2��
$�
$�D�
1�T��#�#�H�b�2D�E�
��
�
�5�
�
�W�
�$���	�	�#�'�'�#�,�'�$��x���Z�\�9���	�	�#�'�'�#�,��I�	�F�:�2�"	
���%)�*�T��S����^�T�*�
�		
�+2�
1��2�
1��$
+s�"E�B8E�'E'�E�E$c���tjtjdtj��dtj��}|j|d�yr�)r�	Attributer�rurMr#)rr�s  r�test_attributez ASTValidatorTests.test_attribute#s:���}�}�S�X�X�c�3�9�9�;�7��c�h�h�j�I���	�	�$�0�1rc	��tjtjdtj��tjd�tj
��}|j
|d�tjdtj
��}tj|tjdtj��tj
��}|j
|d�tjdtj��}|ddfd|dfdd|ffD]M}tj|�}|j
tj||tj
��d��Otjgtj
��}|j
tj||tj
���tj|gtj
��}|j
tj||tj
��d�y)Nr?r�rsr�)	r�	Subscriptr�rur�rMr#�Slice�Tuple)r�subr?r�r��sls      r�test_subscriptz ASTValidatorTests.test_subscript'sk���m�m�C�H�H�S�#�)�)�+�6����Q������T���	�	�#�/�0��H�H�S�#�(�(�*�%���m�m�A�s�x�x��S�Y�Y�[�9�3�8�8�:�F���	�	�#�/�0��H�H�S�#�)�)�+�&����d�O�d�A�t�_�t�T�1�o�E�D����D�!�B��I�I�c�m�m�A�r�3�8�8�:�6�8P�Q�F��Y�Y�r�3�8�8�:�
&���	�	�#�-�-��2�s�x�x�z�2�3�
�Y�Y��s�C�H�H�J�
'���	�	�#�-�-��2�s�x�x�z�2�4L�Mrc	�f�tjtjtjdtj��tj
��gtj
��}tj|gtjd��}|j|d�y)Nr?r,r�)	r�List�Starredr�rMrur�r�r$)rr(�assigns   r�test_starredzASTValidatorTests.test_starred6sk���x�x�
�[�[����#�s�x�x�z�2�C�I�I�K�
@�A�3�9�9�;�
�����T�F�C�L�L��O�4���	�	�&�3�4rc	��|j|dgtj��d�|j|tjdtj��gtj��d�yr�)r#rrMr�ru)rrxs  r�	_sequencezASTValidatorTests._sequence=sS���	�	�#�t�f�c�h�h�j�)�+<�=��	�	�����#�s�y�y�{�+�,�c�h�h�j�9�;S�	
rc�B�|jtj�yr�)r(rr#r�s r�	test_listzASTValidatorTests.test_listCs�����s�x�x� rc�B�|jtj�yr�)r(rrr�s r�
test_tuplezASTValidatorTests.test_tupleFs�����s�y�y�!rc���tjd��5}tjddt�ddlm}ddd�tjd��5}tjddt�|j
t	j
d��ddd�|jD�cgc]}t|j���c}d	g�y#1swY��xYw#1swY�JxYwcc}w)
NTr�r�r�r)r�r�r,r�)
r�r�r�r�rr�r#r,r�r�)rr�r�r�s    r�test_nameconstantz#ASTValidatorTests.test_nameconstantIs���
�
$�
$�D�
1�T��#�#�H�b�2D�E�(�2��
$�
$�D�
1�T��#�#�H�b�2D�E��I�I�c�&�&�q�)�*�2�	
���%)�*�T��S����^�T�*�m�
�	
�2�
1��2�
1��

+s�"C�AC �.C,�C� C)�cpuc�<�tjjtj�}tj
|�D�cgc]}|j
d�s�|��}}|jddg�|D]�}|j|�5tjj||�}t|dd��5}|j�}ddd�tj|�}t||d�ddd���ycc}w#1swY�<xYw#1swY��xYw)Nz.pyztest/test_grammar.pyztest/test_unpack_ex.pyr��utf-8��encodingrP)�os�path�dirnamer�__file__�listdir�endswith�extendrZ�join�open�readrdr[)r�stdlib�fnr�r��fpr�r�s        r�test_stdlib_validatesz'ASTValidatorTests.test_stdlib_validatesYs�����������.�� �j�j��0�G�0��B�K�K��4F��0��G�
���,�.F�G�H��F����f�%��W�W�\�\�&�&�1���"�c�G�4���W�W�Y�F�5��i�i���+����R��(�&�%���H�
5�4��&�%�s0�D�D�/D�:D�+D�D�D�D	rkr?T�carterr�r�.r:�stringr�)�rest�lol�legit)�patterns�	kwd_attrs�kwd_patternsr�r\�xxx�_c
�2�tjdtj��}|jD]�}|j	tj
|d���5tj|tj|tj�g��g��}tj|�}tj|gg�}|jt�5t|dd�ddd�ddd���y#1swY�xYw#1swY��xYw)Nr?r,r�)r�rp)�subject�casesr�rP)rr�rM�_MATCH_PATTERNSrZr��Matchr�rrNr}r:rrr[)r�name_xr�rr�s     r�test_match_validation_patternz/ASTValidatorTests.test_match_validation_pattern�s������#�s�x�x�z�*���+�+�G����c�h�h�w�q�9�:��y�y�"��>�>�'������M�N����0�0��6�����T�F�B�/���&�&�z�2��F�H�f�5�3�;�:�,�3�2��;�:�s%�BD
� D�.D
�D
�D
�
D	)NrPr�)NrErrFrrr�r#r$r&rzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr!r&r(r*r,r.r�requires_resourcerArr��
constant_1�
MatchValue�	pattern_1�
constant_x�	pattern_x�
constant_true�MatchSingleton�pattern_truer�rM�name_carterrru�
MatchSequence�MatchMappingr$�
MatchClass�	MatchStar�MatchAs�MatchOrrOrRr5rrrmrm`ss��2�Z�2�$�*�$��6�0
�d.�(*�2
�:T�


�1�
E�
�	/�A�/�/�(/�(3�;�L�
;�?�/�/�/�.�B�(�/�
6�"	(�(�'�,�+� O�	�
2�
�B2�
N�5�
�!�"�
� �W���u�%�
)�&�
)�����a��J�����z�*�I�����c�"�J�����z�*�I� �C�L�L��&�M�%�3�%�%�d�+�L��#�(�(�8�X�S�X�X�Z�0�K�	�����C�M�M���
�
�h�c�h�h�s�I�C�I�I�K�8�#�x�s�x�x�z�J������
�
�	
�	�����C�M�M���
�
�h�c�h�h�s�H�C�H�H�J�7��i�c�i�i�k�J������
�
�	
�	����|�s�|�|�C�(�)�����|�s�|�|�D�)�*�����|�s�|�|�I�.�/�����8�$�����-�3�-�-�h�7�8�9�����,�3�,�,�.@�c�.@�.@��.J�-K�L�M�N�����*�m�4�y�k�B�����
�J�'�)�Y�)?�f�	
�	����
�K�C�K�K����������
�(C�X�S�X�X�Z�P�Q�
�	�"��	
�
	�����C�M�M�-�#�-�-�
�C������D�c�8�3�8�8�:�V����		
�	�����"���	�{�	
�	�����"��)��	
�	�����(�c�(�(��2�3���		
�	�����=�3�=�=�?�"3�r�PR�	
�	�����"��-�#�-�-�/�AR�	
�	�������h�#��		
�	����=�3�=�=��0�1�2������!�����B������Y�K� �����Y�	�+=�3�+=�+=�e�+D�E�F���������
�
�3������=�3�=�=��-�.�/������R�c�*�IE�O�N6rrmc�j�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
ejd	��Z
d
�Zd�Zy)
�
ConstantTestsz$Tests on the ast.Constant node type.c��tjd�}|jdj}tj|��}tj
||�||jd_t
|dd�}i}t||�|dS)Nzx = 123rr�rcrPr?)rrdrpr1r�rr[rP)rr1rgr�new_noder�ras       r�compile_constantzConstantTests.compile_constant�sv���y�y��#���y�y��|�!�!���<�<�e�,�����(�D�)�%��	�	�!����t�Z��0��
���T�2���#�w�rc���|jt�5}|jgd��ddd�|jt	j
�d�y#1swY�/xYw)Nr:z%got an invalid type in Constant: list)r:r=rgr,r�rG)rrJs  r�test_validationzConstantTests.test_validation�sH��
�
�
�y�
)�R��!�!�)�,�*�����R�\�\�*�,S�T�*�
)�s�A�A!c���dddtdt�fD]@}|j|��5|j|�}|j	||�ddd��By#1swY�MxYw)NFTr)�const)r�rSrZrgr�)rrkr1s   r�test_singletonszConstantTests.test_singletons�sW���E�4��3�	��D�E����E��*��-�-�e�4���
�
�e�U�+�+�*�E�*�*�s�$A�A"	c	�>�d}tdh�}td�D]}|df}t|dh�}�ddddd	td
�td�||f	}|D]@}|j|��5|j	|�}|j||�ddd��By#1swY�MxYw)
N)rkrkr�r8�{g�^@y�^@�unicode�bytesr�rSr�)rSr�r�rZrgr,)r�nested_tuple�nested_frozensetr^rKr1�results       r�test_valueszConstantTests.test_values�s�����$�a�S�>���1�X�E�(�!�,�L�(�*:�A�)>�?���
������'�N��k�"���

���E����E��*��.�.�u�5��� � ���/�+�*��*�*�s�$$B�B	c��tjd�}|jdjd}tjd��}tj
||�||jdjd<|j
t�5}t|dd�ddd�|jtj�d�y#1swY�/xYw)N�x = 1rrkr�rCrPz6expression which can't be assigned to in Store context)rrdrp�targetsr�rr:rrr[r,r�rG)rrgr��
new_targetrJs     r�test_assign_to_constantz%ConstantTests.test_assign_to_constant�s����y�y��!�����1��%�%�a�(���\�\��*�
����*�f�-�",��	�	�!����Q��
�
�
�z�
*�b��D�(�F�+�+���������G�	
�+�
*�s�C�Cc�x�tjd�}|jtj|�d�y)Nz'docstring'
x = 1�	docstring)rrdr,r'r�s  rr(z ConstantTests.test_get_docstrings,���y�y�-�.������*�*�4�0�+�>rc���t|dd�}g}tj|�D]<}|jdk(s|jdk(s�"|j	|j
��>|S)NrcrP�
LOAD_CONST�RETURN_CONST)r[�dis�get_instructions�opnamer�argval)rrg�co�consts�instrs     r�get_load_constzConstantTests.get_load_constsZ���T�:�v�
.�����)�)�"�-�E��|�|�|�+�u�|�|�~�/M��
�
�e�l�l�+�.��
rc�v�gd�}dj|D�cgc]}dj|���c}�}|dz
}|jtdf�t	j
|�}|j
|j|�|�t|j|�D]v\}}t|tj�sJt	j|���t	j|��}t	j||j�||_�x|j
|j|�|�ycc}w)N)	NTF�|g@y@rorpr:rlzx={!r}z
x = ...r�)r;r�r:r�rrdr,r�rYrprr�r�r�rr1)rr�rkr�rgr%rfs       r�test_load_constzConstantTests.test_load_consts���R���y�y�f�E�f�U�(�/�/�%�0�f�E�F�������
�
�x��&�'��y�y��������,�,�T�2�F�;�!����F�3�M�F�E��f�c�j�j�1�C�3�8�8�F�3C�C�1��|�|�%�0�H����h����5�#�F�L�	4�	
����,�,�T�2�F�;��Fs�D6c��tjd�}|jdj}tjd��}tj
||j�||_tjd��}tj
||j�||_|jtj|�d�y)Nz1 + 2rrjr�y4@y$@4@)
rrdrpr1r�rr(r*r,r�)rrg�binop�new_left�	new_rights     rr?zConstantTests.test_literal_eval)s����y�y��!���	�	�!��"�"���<�<�b�)�����(�E�J�J�/���
��L�L�s�+�	����)�U�[�[�1��������)�)�%�0�(�;rc���tjdd��j}|j|jd�|j|j
d�tjdd��j}|j|jd�|j|j
d�tjdd��j}|j|jd�|j|j
d�tjdd��j}|j|jd	�|j|j
d�y)
Nz"x"rRrr?zu"x"r�zr"x"zb"x"�x)rrdrpr,r1rX)rr�s  r�test_string_kindzConstantTests.test_string_kind7s����I�I�e�&�)�.�.��������#�&��������&��I�I�f�6�*�/�/��������#�&��������%��I�I�f�6�*�/�/��������#�&��������&��I�I�f�6�*�/�/��������$�'��������&rN)rErrFrnrgrirlrtryr(r�rr�r�r?r�r5rrrdrd�sM��.��U�
,�0�,

�?��
���<��<�&<�'rrdc���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"y!)"�EndPositionTestsz�Tests for end position of AST nodes.

    Testing end positions of nodes requires a bit of extra care
    because of how LL parsers work.
    c�t�|j|j|�|j|j|�yr�)r,rqrs)rr.rqrss    r�_check_end_poszEndPositionTests._check_end_posPs.������,�,�j�9�����0�0�.�Arc�P�|jtj||�|�yr�)r,r�get_source_segment)rr�r.�contents    r�_check_contentzEndPositionTests._check_contentTs������/�/���A�7�Krc�Z�tj|�jdjS)Nr)rrdrpr1r�s  r�_parse_valuezEndPositionTests._parse_valueWs#���y�y��|� � ��#�)�)�)rc��d}|j|�}|j||jd�|j||jjdd�|j||jjd�y)Nzlambda x, *y: Noner�rr?r�)r�r�rpr�r<)rr��lams   rr�zEndPositionTests.test_lambda\sf�� ������"�����A�s�x�x��0����A�s�x�x�}�}�Q�/��5����A�s�x�x����4rc�L�td�j�}tj|�jd}|j|dd�|j
||jdd�|j
||jjdd�|j
||jjdjd�|j
||jjd�|j
||jjjd	�y)
Nz�
            def func(x: int,
                     *args: str,
                     z: float = 0,
                     **kwargs: Any) -> bool:
                return True
            rr+�zreturn Truezx: intrRzkwargs: Any�Any)
rr�rrdrpr�r�r��
annotationr��rr��fdefs   r�
test_func_defzEndPositionTests.test_func_defcs�����
����
	
��y�y��|� � ��#�����D�!�R�(����A�t�y�y��|�]�;����A�t�y�y�~�~�a�0�(�;����A�t�y�y�~�~�a�0�;�;�U�C����A�t�y�y���
�>����A�t�y�y���9�9�5�Arc��d}|j|�}|j||jd�|j||jdjd�|j||jdjd�y)Nzfunc(x, y=2, **kw)rr�2rk�kw)r�r�rrr1�rr�rs   rrzEndPositionTests.test_callsso�� ��� � ��#�����A�t�y�y�&�1����A�t�}�}�Q�/�5�5�s�;����A�t�}�}�Q�/�5�5�t�<rc��d}|j|�}|j||jd�|j|dd�y)Nzx[0]()zx[0]rkr<)r�r�rr�r�s   r�test_call_noargsz!EndPositionTests.test_call_noargszs?����� � ��#�����A�t�y�y�&�1����D�!�Q�'rc� �td�j�}tj|�jd}|j|dd�|j
||jdd�|j
||jdd�y)Nz?
            class C(A, B):
                x: int = 0
        rr8�rk�Bz
x: int = 0)rr�rrdrpr�r�r��rr��cdefs   r�test_class_defzEndPositionTests.test_class_def�s}����

��U�W�	
��y�y��|� � ��#�����D�!�R�(����A�t�z�z�!�}�c�2����A�t�y�y��|�\�:rc��d}tj|�jd}|j||jdj
d�y)Nz$class S(metaclass=abc.ABCMeta): passrzabc.ABCMeta)rrdrpr�rr1r�s   r�
test_class_kwzEndPositionTests.test_class_kw�s@��2���y�y��|� � ��#�����A�t�}�}�Q�/�5�5�}�Erc���td�j�}tj|�jd}|j|dd�|j|jdd�y)Nzh
            x = """Some multi-line text.

            It goes on starting from same indent."""
        rr��(�rr�rrdrpr�r1�rr�r%s   r�test_multi_line_strz$EndPositionTests.test_multi_line_str�s_����

��U�W�		
�
���1��"�"�1�%�����F�A�r�*����F�L�L�!�R�0rc���td�j�}tj|�jd}|j|dd�|j|jdd�y)NzB
            x = "first part" \
            "second part"
        rr8r,r�r�s   r�test_continued_strz#EndPositionTests.test_continued_str�s_����

��U�W�	
����1��"�"�1�%�����F�A�r�*����F�L�L�!�R�0rc�P�td�j�}tj|�}|jd}|jd}|jd}|jd}|jd}|j|dd�|j|dd	�|j|d	d
�|j|dd�|j|dd�|j
||jd
�|j
||jdd�|j
||jdjd�|j
||jd�|j
||jdd�|j
||jdjd�y)Na
            while True:
                pass

            if one():
                x = None
            elif other():
                y = None
            else:
                z = None

            for x, y in stuff:
                assert True

            try:
                raise RuntimeError
            except TypeError as e:
                pass

            pass
        rrkr8r�r,r�r�r�r��r�zx = Nonezother()�x, yzraise RuntimeErrorr=)rr�rrdrpr�r�rr0r��handlersr)rr�r��
while_loop�if_stmt�for_loop�try_stmt�	pass_stmts        r�test_suiteszEndPositionTests.test_suites�so��
��

�(�U�W�)	
�*�i�i��l���X�X�a�[�
��(�(�1�+���8�8�A�;���8�8�A�;���H�H�Q�K�	����J��1�-����G�Q��+����H�b�"�-����H�b�!�,����I�r�1�-����A�z����7����A�w�|�|�A��
�;����A�w�~�~�a�0�5�5�y�A����A�x����7����A�x�}�}�Q�/�1E�F����A�x�0�0��3�8�8�+�Frc��d}|j|�}|jdj}|j||d�y)Nzx = f"abc {x + y} abc"rkzx + y)r�rKr1r��rr��fstrr�s    r�test_fstringzEndPositionTests.test_fstring�s<��$��� � ��#�����A��$�$�����A�u�g�.rc�$�td�j�}|j|�}|jdj}|j|dd�|j
||jd�|j
||jd�y)Nz�
            f"""Some multi-line text.
            {
            arg_one
            +
            arg_two
            }
            It goes on..."""
        rkr+r��arg_one�arg_two)	rr�r�rKr1r�r�r(r*r�s    r�test_fstring_multi_linez(EndPositionTests.test_fstring_multi_line�s�����

��U�W�	
�� � ��#�����A��$�$�����E�1�a�(����A�u�z�z�9�5����A�u�{�{�I�6rc���td�j�}tj|�jd}|j|dd�|j|jddd�y)NzT
            from x.y.z import (
                a, b, c as c
            )
        rr�rkr8r�)rr�rrdrpr�rz)rr�r�s   r�test_import_from_multi_linez,EndPositionTests.test_import_from_multi_line�sc����

��U�W�		
�
�i�i��l����"�����C��A�&����C�I�I�a�L�!�R�0rc��d}d}td�j�}t|j|||f�\}}}|j	||j
d�|j	||j
jd�|j	||jjd�|j	||jjd�|j	||jjdjd	�|j	||jjd
jd�|j|dd�y)
Nz
f()[1, 2] [0]zx[ a.b: c.d]zN
            x[ a.b: f () ,
               g () : c.d
              ]
        z	f()[1, 2]z1, 2za.bzc.dr�f ()rk�g ()r�)rr��mapr�r�r1r�r�r��eltsr�)r�s1�s2�sm�i1�i2r�s       r�test_sliceszEndPositionTests.test_slices�s��
��
��
��
��U�W�		�
��*�*�R��R�L�9�
��B�����B����+�6����B�������7����B�������6����B�������6����B����
�
�a� 0� 6� 6��?����B����
�
�a� 0� 6� 6��?����B��1�%rc�@�td�j�}|j|�}|j|dd�|j	||j
d�|j	||jd�|j	||jj
d�y)NzF
            (1 * 2 + (3 ) +
                 4
            )
        r8r<�4z1 * 2 + (3 )�3)rr�r�r�r�r*r()rr�r�s   r�
test_binopzEndPositionTests.test_binop�s�����

��U�W�		
�
�!�!�!�$�����E�1�a�(����A�u�{�{�C�0����A�u�z�z�>�:����A�u�z�z�/�/��5rc���td�j�}tj|�jdj
}|j
|dd�|j||jdd�y)Nz{
            if (one_condition and
                    (other_condition or yet_another_one)):
                pass
        rr8�,rkz"other_condition or yet_another_one)	rr�rrdrprr�r�rK)rr��bops   rr�zEndPositionTests.test_boolop	sj����

��U�W�		
�
�i�i��l����"�'�'�����C��B�'����A�s�z�z�!�}�.R�Src��d}d}d}td�j�}t|j||||f�\}}}}|j	||d�|j	||d�|j	||d�|j|dd	�y)
Nzx = () ;z	x = 1 , ;zx = (1 , 2 ) ;z?
            x = (
                a, b,
            )
        r�z1 ,z(1 , 2 )r�rk)rr�r�r�r�r�)	rr�r��s3r��t1�t2�t3�tms	         r�test_tupleszEndPositionTests.test_tuples	s���
��
��
��
��
��U�W�		�
�T�.�.��R��R�0@�A���B��B����B��D�)����B��E�*����B��J�/����B��1�%rc��d}|j|�}|j|||�|j||jdd�y)Nz
func(x. y .z)rzx. y .z)r�r�r�r�s   r�test_attribute_spacesz&EndPositionTests.test_attribute_spaces$	sC����� � ��#�����A�t�Q�'����A�t�y�y��|�Y�7rc��d}tj|�jdj}|j	t|�jd�|j||d�d|z}tj|�jdjj}|j	t|�jd�|j||d�y)Nz( ( ( a + b ) ) )rr.za + b�await )rrdrpr1r,rrEr�)rr�r�r�s    r�test_redundant_parenthesisz+EndPositionTests.test_redundant_parenthesis*	s������I�I�a�L���a� �&�&������a��)�)�7�3����A�q�'�*�
��\���I�I�b�M���q�!�'�'�-�-������a��)�)�7�3����B��7�+rc��d}|D]�\}}|j|�5tj|�jdj}|jt
|�j|�|j|||�d|z}tj|�jdjj}|jt
|�j|�|j|||�ddd���y#1swY��xYw)N))z( ( ( a ) ) ) ( )r)z( ( ( a ) ) ) ( b )r)z( ( ( a ) ) ) [ b ]r)z( ( ( a ) ) ) . brrr�)	rZrrdrpr1r,rrEr�)rr�r�r�r�r�s      r�(test_trailers_with_redundant_parenthesisz9EndPositionTests.test_trailers_with_redundant_parenthesis4	s���
���D�A�q����a���I�I�a�L�%�%�a�(�.�.��� � ��a��!1�!1�1�5��#�#�A�q�!�,���\���I�I�b�M�&�&�q�)�/�/�5�5��� � ��a��!1�!1�1�5��#�#�B��1�-�!��� ��s�CC?�?D		c��d}d}|j|�}|j|�}|j||jdd�|j||jdd�|j||jdd�|j||jdd	�|j||jdd
�y)Nz[{}, {1, }, {1, 2,} ]z{a: b, f (): g () ,}rz{}rkz{1, }r8z{1, 2,}r�r�)r�r�r�rJrK)rr�r��c1�c2s     r�
test_displayszEndPositionTests.test_displaysE	s���
$��
#��
�
�
�r�
"��
�
�
�r�
"�����B�����
�D�1����B�����
�G�4����B�����
�I�6����B�����
�F�3����B��	�	�!��f�5rc��td�j�}|j|�}|j|dd�|j	||j
djd�|j	||jj
djd�|j	||jj
djdd�|j	||jj
djd�y)	Nza
            x = [{x for x, y in stuff
                  if cond.x} for stuff in things]
        r8�%r�things�stuffzcond.xr�)
rr�r�r�r��
generatorsr��elt�ifsr�)rr��cmps   r�test_comprehensionsz$EndPositionTests.test_comprehensionsP	s�����

��U�W�	
�����"�����C��B�'����A�s�~�~�a�0�5�5�x�@����A�s�w�w�1�1�!�4�9�9�7�C����A�s�w�w�1�1�!�4�8�8��;�X�F����A�s�w�w�1�1�!�4�;�;�V�Drc�"�td�j�}tj|�jd}|j||jdjd�|j||jdjd�y)NzT
            async def f():
                yield x
                await y
        rzyield xrkzawait y)rr�rrdrpr�r1r�s   r�test_yield_awaitz!EndPositionTests.test_yield_await\	sw����

��U�W�		
�
�y�y��|� � ��#�����A�t�y�y��|�1�1�9�=����A�t�y�y��|�1�1�9�=rc���td�j�}td�j�}|j|�}|jt	j
||j�|�y)NzD
            x = (
                a, b,
            ) + ()
        z;
            (
                a, b,
            )
        )rr�r�r,rr�r()r�s_orig�s_tupler�s    r�test_source_segment_multiz*EndPositionTests.test_source_segment_multif	sm����
��U�W�		�
��
��U�W�		�
�!�!�&�)������/�/���
�
�C�W�Mrc���td�j�}d}tj|�jd}|jtj||jdd��|�y)Nuf
            class C:
                def fun(self) -> None:
                    "ЖЖЖЖЖ"
        u/    def fun(self) -> None:
        "ЖЖЖЖЖ"rT��padded�rr�rrdrpr,r�)rr��s_methodr�s    r�test_source_segment_paddedz+EndPositionTests.test_source_segment_paddedt	sh����
��U�W�		�
I���y�y�� �%�%�a�(������"�"�6�4�9�9�Q�<��E�x�	
rc��d}tj|�j\}}}}}|j||d�|j||d�|j||d�|j||d�|j||d�y)Nz!v = 1
w = 1
x = 1

y = 1
z = 1
zv = 1zw = 1rvzy = 1zz = 1)rrdrpr�)rr�r�r�r?r�r�s       r�test_source_segment_endingsz,EndPositionTests.test_source_segment_endings�	s~��7���	�	�!��)�)�
��1�a��A����A�q�'�*����A�q�'�*����A�q�'�*����A�q�'�*����A�q�'�*rc���td�j�}d}tj|�jd}|jtj||jdd��|�y)Nzb
            class C:
              	  def fun(self) -> None:
              	      pass
        z+  	  def fun(self) -> None:
  	      passrTrr)rr�rr�s    r�test_source_segment_tabsz)EndPositionTests.test_source_segment_tabs�	sd����

��U�W�		
�
I���y�y��|� � ��#������/�/��4�9�9�Q�<��M�x�Xrc�J�d}tj|�j\}}}|j||d�|j||d�|j||d�d}tj|�jd}|j|||j	��y)Nz3def f():
  pass
def g():
  pass
def h():
  pass
zdef f():
  passzdef g():
  passzdef h():
  passz"def f():
  a = 1
  b = 2
  c = 3
r)rrdrpr��rstrip)rr�rjr��hs     r�test_source_segment_newlinesz-EndPositionTests.test_source_segment_newlines�	s���J���)�)�A�,�#�#���1�a����A�q�"4�5����A�q�"4�5����A�q�"6�7�5���I�I�a�L���a� �����A�q�!�(�(�*�-rc��d}tj|�j\}}}}|`|`|`|`|jtj||��|jtj||��|jtj||��|jtj||��y)Nzv = 1
w = 1
x = 1

y = 1
)	rrdrpr&rqr'rsrMr�)rr�r�r�r?r�s      r� test_source_segment_missing_infoz1EndPositionTests.test_source_segment_missing_info�	s���0���Y�Y�q�\�&�&�
��1�a��
�H�
�L�
�L�
�����#�0�0��A�6�7����#�0�0��A�6�7����#�0�0��A�6�7����#�0�0��A�6�7rN)#rErrFrnr�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rrr5rrr�r�Is����B�L�*�
5�B� =�(�;�F�
1�1�*G�X/�7� 1�&�"
6�T�
&�8�,�.�"	6�
E�>�N�

�+�	Y�	.�
8rr�c��eZdZd�Zy)�BaseNodeVisitorCasesc����G�fd�d|j�}tjtd��}|�}g�t	j
d��5}t	jddt�|j|�ddd�|j�gd��|jD�cgc]}t|j���c}gd	��y#1swY�SxYwcc}w)
Nc�@��eZdZ�fd�Z�fd�Z�fd�Z�fd�Z�fd�Zy)�=BaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitorc�V���j|jd|jf�y)Nr�)rr&r��rr�logs  �r�	visit_NumzGBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_Num�	�����
�
�D�K�K�����7�8rc�V���j|jd|jf�y)Nr��rr&r�rs  �r�	visit_StrzGBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_Str�	rrc�V���j|jd|jf�y)Nr�rrs  �r�visit_ByteszIBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_Bytes�	s����
�
�D�K�K��$�&�&�9�:rc�V���j|jd|jf�y)Nr�)rr&r1rs  �r�visit_NameConstantzPBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_NameConstant�	s����
�
�D�K�K�����D�Erc�B���j|jddf�y)Nr�.)rr&rs  �r�visit_EllipsiszLBaseNodeVisitorCases.test_old_constant_nodes.<locals>.Visitor.visit_Ellipsis�	s����
�
�D�K�K��S�9�:rN)rErrFrrrr!r#)rs�r�Visitorr�	s���
9�
9�
;�
F�
;rr$z�            i = 42
            f = 4.25
            c = 4.25j
            s = 'string'
            b = b'bytes'
            t = True
            n = None
            e = ...
            Tr�r�r�))rkr�r6)r8r�r�)r�r�r�)r,r�rC)r+r�rp)r<r�T)r�r�N)r�r�.)
�+visit_Num is deprecated; add visit_Constantr�r%r�r%r�z+visit_Str is deprecated; add visit_Constantr�z-visit_Bytes is deprecated; add visit_Constantr��4visit_NameConstant is deprecated; add visit_Constantr&z0visit_Ellipsis is deprecated; add visit_Constant)�
visitor_classrrdrr�r�r�r��visitr,r�r�)rr$r��visitorr�r�rs      @r�test_old_constant_nodesz,BaseNodeVisitorCases.test_old_constant_nodes�	s����	;�d�(�(�	;� �i�i��	�	
�
���)����
�
$�
$�D�
1�T��#�#�H�b�2D�E��M�M�#��2�	
����	
�	
�	
���%)�*�T��S����^�T�*�
�	
�!2�
1��"
+s�-C�.C!�CN)rErrFr*r5rrrr�	s��@
rrc�$�eZdZejZy)�NodeVisitorTestsN)rErrFr�NodeVisitorr'r5rrr,r,�	s���O�O�Mrr,c�H�eZdZejZd�Zd�Zd�Zd�Z	d�Z
d�Zy)�NodeTransformerTestsc��tjt|��}tjt|��}|�}tj|j	|��}|j||�yr�)rrdrrNr(�assertASTEqual)r�tranformer_class�initial_code�
expected_code�initial_ast�expected_ast�
tranformer�
result_asts        r�assertASTTransformationz,NodeTransformerTests.assertASTTransformation�	s[���i�i��|� 4�5���y�y��
�!6�7��%�'�
��.�.�z�/?�/?��/L�M�
����J��5rc�d�d}d}Gd�dtj�}|j|||�y)Nzdef func(arg) -> SomeType: ...zdef func(arg): ...c�,�eZdZdejfd�Zy)�ENodeTransformerTests.test_node_remove_single.<locals>.SomeTypeRemoverrc�H�|j|�|jdk(ry|S)N�SomeType)�
generic_visitr�r�s  r�
visit_NamezPNodeTransformerTests.test_node_remove_single.<locals>.SomeTypeRemover.visit_Name
s$���"�"�4�(��7�7�j�(���rN)rErrFrr�r@r5rr�SomeTypeRemoverr<
���
�s�x�x�
rrA�r�NodeTransformerr9)rr��expectedrAs    r�test_node_remove_singlez,NodeTransformerTests.test_node_remove_single
s2��/��'��	�c�1�1�	�	
�$�$�_�d�H�Erc�d�d}d}Gd�dtj�}|j|||�y)NzM
        def func(arg):
            print(arg)
            yield arg
        �7
        def func(arg):
            print(arg)
        c�,�eZdZdejfd�Zy)�ENodeTransformerTests.test_node_remove_from_list.<locals>.YieldRemoverrc�r�|j|�t|jtj�ry|Sr�)r?rr1rr�r�s  r�
visit_ExprzPNodeTransformerTests.test_node_remove_from_list.<locals>.YieldRemover.visit_Expr
s*���"�"�4�(��d�j�j�#�)�)�4���rN)rErrFrrErLr5rr�YieldRemoverrJ
rBrrMrC)rr�rErMs    r�test_node_remove_from_listz/NodeTransformerTests.test_node_remove_from_list
s6����
��	�3�.�.�	�	
�$�$�\�4��Brc�d�d}d}Gd�dtj�}|j|||�y)Nz0
        class DSL(Base, kw1=True): ...
        zE
        class DSL(Base, kw1=True, kw2=True, kw3=False): ...
        c�,�eZdZdejfd�Zy)�BNodeTransformerTests.test_node_return_list.<locals>.ExtendKeywordsrc���|j|�|jdk(rS|tjdtjd��tjdtjd��gS|S)N�kw1�kw2T�kw3F)r?r�rr�r�r�s  r�
visit_keywordzPNodeTransformerTests.test_node_return_list.<locals>.ExtendKeywords.visit_keyword/
s^���"�"�4�(��8�8�u�$�����E�3�<�<��+=�>����E�3�<�<��+>�?���
�rN)rErrFrr�rVr5rr�ExtendKeywordsrQ.
s��
�#�+�+�
rrWrC)rr�rErWs    r�test_node_return_listz*NodeTransformerTests.test_node_return_list&
s6������		�S�0�0�		�	
�$�$�^�T�8�Drc�d�d}d}Gd�dtj�}|j|||�y)NrHz5
        def func(arg):
            log(arg)
        c�,�eZdZdejfd�Zy)�9NodeTransformerTests.test_node_mutate.<locals>.PrintToLogrc���|j|�t|jtj�r*|jj
dk(rd|j_|S)N�printr)r?rrrr�r�r�s  r�
visit_CallzDNodeTransformerTests.test_node_mutate.<locals>.PrintToLog.visit_CallF
sA���"�"�4�(��d�i�i����2�t�y�y�|�|�w�7N�#(�D�I�I�L��rN�rErrFrrr^r5rr�
PrintToLogr[E
rBrr`rC�rr�rEr`s    r�test_node_mutatez%NodeTransformerTests.test_node_mutate;
s6������
	��,�,�	�	
�$�$�Z��x�@rc�d�d}d}Gd�dtj�}|j|||�y)NrHzH
        def func(arg):
            logger.log(arg, debug=True)
        c�,�eZdZdejfd�Zy)�:NodeTransformerTests.test_node_replace.<locals>.PrintToLogrc
���|j|�t|jtj�r�|jj
dk(r�tjtjtjdtj���dtj���|jtjdtjd��g��S|S)	Nr]�logger)r�r)r�r��debugT)rr�r)r?rrrr�r�rrrMr�r�r�r�s  rr^zENodeTransformerTests.test_node_replace.<locals>.PrintToLog.visit_CallY
s����"�"�4�(��d�i�i����2�t�y�y�|�|�w�7N��8�8� �]�]��H�H�X�3�8�8�:�>�!&� #���
��
"�Y�Y�"%�+�+�g�s�|�|�D�7I�"J�!K����rNr_r5rrr`reX
s��
�s�x�x�
rr`rCras    r�test_node_replacez&NodeTransformerTests.test_node_replaceN
s6������

	��,�,�
	�	
�$�$�Z��x�@rN)rErrFrrDr'r9rFrNrXrbrir5rrr/r/�	s0���'�'�M�6�
F�C�,E�*A�&Arr/c�$�eZdZd�Zd�Zd�Zd�Zy)�ModuleStateTestsc��d}d}d}t|||tj��}t|||�}|j|tj
�y)Nzx + 1rcrR)�flags)r[rr\r��types�CodeType)rr��filenamerr`s     r�check_ast_modulez!ModuleStateTests.check_ast_modulen
sM���������4��4�s�7H�7H�I���x��4�0�����d�E�N�N�3rc�8�tjtjdd�5tjd=ddl}tjd=ddl}|j�ddd�~~tj�|j�y#1swY�0xYw)N�_astr)r�	swap_item�sys�modulesrsrqrL)r�ast1r@s   r�test_reload_modulez#ModuleStateTests.test_reload_module{
sp��
�
�
�s�{�{�F�D�
9����F�#�����F�#���!�!�#�:�
����������:�
9�s�;B�Bc���t���fd�}tjtjdd�5tjd=tj
td|�5|j�|jdtj�ddl	}|j|��ddd�ddd�y#1swY�xYw#1swYyxYw)Nc�.���tj|<�Sr�)rurv)rr�r��lazy_mods   �r�	my_importz4ModuleStateTests.test_sys_modules.<locals>.my_import�
s��� (�C�K�K����Orrs�
__import__r)�objectrrtrurvr`rxrq�assertNotInrsr�)rr|rsr{s   @r�test_sys_modulesz!ModuleStateTests.test_sys_modules�
s�����8��	��
�
�s�{�{�F�D�
9����F�#��"�"�8�\�9�E��%�%�'�� � �����5���
�
�d�H�-�F�:�
9�F�E��:�
9�s$�-C�#AB;�*C�;C	�C�Cc�h�td�}tj|�}|j|d�y)Nap
            import _ast
            import ast
            import gc
            import sys
            import types

            # Create _ast.AST subclasses instances and call PyAST_Check()
            ast_tree = compile('x+1', '<string>', 'eval',
                               flags=ast.PyCF_ONLY_AST)
            code = compile(ast_tree, 'string', 'eval')
            if not isinstance(code, types.CodeType):
                raise AssertionError

            # Unloading the _ast module must not crash.
            del ast, _ast
            del sys.modules['ast'], sys.modules['_ast']
            gc.collect()
        r)rr�run_in_subinterpr,)rr��ress   r�test_subinterpreterz$ModuleStateTests.test_subinterpreter�
s5����
��&�&�&�t�,������a� rN)rErrFrqrxr�r�r5rrrkrkj
s��4� �$.�,!rrkc��eZdZd�Zy)�ASTMainTestsc��d}tjtj|�d��}tj�5}t
jj|d�}t|dd��5}|j|�ddd�tjdd	|�\}}ddd�|jjd
�|j|j�|jj!d�j��|j|j"d�y#1swY��xYw#1swY��xYw)
Nzprint(1, 2, 3)r�r�ztest_module.pyr�r1r2z-mrr�utf8r)rr�rdr�temp_dirr4r5r;r<�writer�run_python_until_endr,�err�
splitlines�out�decode�rc)rr�rE�tmp_dirrprjr�rKs        r�test_cli_file_inputz ASTMainTests.test_cli_file_input�
s������8�8�C�I�I�d�O�A�6��
�
�
�
!�W��w�w�|�|�G�-=�>�H��h��g�6�!�����
�7�"�7�7��e�X�N�F�C��	"�	
������#�&�����,�,�.������v�0F�0Q�0Q�0S�T��������#�
7�6��"�
!�s$�/D8�0D,�"D8�,D5	�1D8�8EN)rErrFr�r5rrr�r��
s��$rr�)-rrxrr�r4r�rur�rnr�r�rJ�	functoolsrrrr�test.support.import_helperr�test.supportrr�test.support.ast_helperr	�test.test_ast.utilsr
�test.test_ast.snippetsrrr
rrr�TestCaserr�rmrdr�rr,r/r�rkr�r5rr�<module>r�s,��
��
��	�	�
���������:�1�0�(���
D7��!�!�D7�N|=�h�'�'�|=�~
c	6��)�)�c	6�L@'�H�%�%�@'�F`8�x�(�(�`8�FB
�B
�J$�+�X�->�->�$�rA�<�)=�x�?P�?P�rA�j	���O!�x�(�(�O!��O!�d$�8�$�$�$r

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