Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_ast.cpython-310.pyc
o

�9j��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZdd�Z
gd�ZdgZgd�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZejGdd�dej��Zdd�Zgddggf�ddggf�dddddggdggdgfd ggddfggf�ddd!ddggdggdgfd"ggddfggf�ddd#ddgd$gdggdgfd%ggddfggf�ddd&ddgd$gdggdd'gfd(ggddfggf�ddd)ddggd*ggdgfd+ggddfggf�ddd,ddggdggd-gfd.ggddfggf�ddd/ddggd0�d1d2gd3gd4d5d6d7d8gd9fd:d;ggfgfd<ggddfggf�dd=d>d?ggd@ggfggf�dd=dAd?ggdBggfggf�dd=d,d?dCggd.ggfggf�ddd&ddggdggdgfdDggddfggf�ddEdFdGgfggf�ddHdFdIgdJdfggf�ddHdKdLdMdNdOgdPfgdQdfggf�ddHdRdLdFdSdTgdPfgdUdfggf�ddHdRd7dFdSdTgdPfgdUdfggf�ddVggf�ddWdXdYdZd[ggdfggf�dd\d>d]d@ggfggf�dd^dRd_d`ggfggf�dd^dadbdcgd^dddedfggfgfggf�dd^dgdbdcgd^dhdedfgdigfgfggf�ddjdkdlgdmgdfggf�ddjdndldogdpgdfggf�ddqdndrdsdtduggfdfggf�ddvdadcgdwdddxddfgfgggfggf�ddvdadcgggdfgfggf�ddyggf�ddzd{d|gfggf�dd}dkd~dgdfggf�dd�d�d�gfggf�dd�ggf�dd�ggf�ddWd&dYdZd�ggdfggf�ddWd�dYdZd�ggdfggf�ddWd)dLd�d�d�gdPfd�d+ggdfggf�ddWd�dLd�d�d�gdPfd�d�ggdfggf�ddWd�d7d�d�d�gdPfd�d�ggdfggf�dd�d�d�d�dLd�d�d�gd9fd�dLd�d�d�gdPfd�gdfgffggf�dd�d�d�d�d�d�d�d�d�gdfd�d�d�d�gdfgffggf�dd�d�d�d�d�d�d�dLd�d�d�gdPfd�gdfgffggf�dd�d�d�d�d�d�d�d�d�gdfgffggf�dd�d&d�d&d�d�dLd�d�d�gdPfd�gdfgffggf�dd�d�ddggdggdgfd�d�d�d�d�drd�d�ggfffggddfggf�dd�d�ddggdggdgfd�d�d�d�d�gd�gdfggddfggf�dd�d�ddggdggdgfd�d�d�gd�gdfggddfggf�dd�d#d:d#dd�gd:d�dJgd�gfd�gffggf�dd�d>d�d>d�d�d�d�d�d�gfd9fd�gffggf�dd�d�ddggdggdgfd�d�d�d�d�d�d�d�gd�fgffggddfggf�ddd�ddggdggdgfd�gd�drd�d�ggfdrd�d�d�ggfgddfggf�dd�d�ddggdggdgfd�gd�drd�d�ggfdrd�d�d�ggfgddfggf�dd=d�d?ggd�gd�drd�d�ggfdrd�d�d�ggfgfggf�ddd�ddggdggdgfd�gdrd�d�d�d�d�d�d�d�gdfgfggfgddfggf�ddd�ddggdggdgfd�gd�gddfggf�dd�ggf�ddd)ddd$ggdggdgfd+ggddfggf�ddd�ddd$ggd�dggdgfd�ggddfggf�ddd!ddd$gd�gdd�d�gddgdgfd�ggddfggf�ddd�ddd$gd�gdd�d�gddgd�gfd�ggddfggf�ddd�ddd$ggdggdd�gfd�ggddfggf�ddd!ddd$gd�d�gdggdgd��fd�ggddfggf�dddAddd$gd�gdd�gd�gdd�d�gfd�ggddfggf�ddd�ddd$gd�gdd�gdgdd�d�gfd�ggddfggf�ddd�ddd$gd�gdd�gd�gd�d�d�gfd�ggddfggf�ddd�ddd$gd�gdd�gdg�dd�d�gf�dggddfggf�Z�d�dgfgZg�d��d�ddK�d�d�d	gff��d
��d��d�d�d
dggdggdgf�dff��dd:dK�dg�dgff��dd:�dggff��dd�dK�dgff��dd:�d�dg�dgff��dd�d�d�d�d��d�dgdfgff��dd�d�d�d�d��d�dgdfgff��dd�d�dL�d�d�dgd9fd�dLd��d�dgdPf�dgdfgff��ddϐddL�d�d�dgd9fd�dL�dd�d gdPf�d!gdfgff��ddϐddL�d�d�dgd9fd�d7�dd�d gdPf�d!gdfgff��dd�d�dL�d�d�dgd9fd�dLd��d�dgdPf�dgdfgff��dd��ddL�d�d�dgd9fd�dL�dd�d gdPf�d!gdfgff��dd��ddL�d�d�dgd9fd�d7�dd�d gdPf�d!gdfgff��dd�d�dL�d�d�dgd9fd�dLd��d�dgdPf�dgdfgff��dd��ddL�d�d�dgd9fd�dL�dd�d gdPf�d!gdfgff��dd��ddL�d�d�dgd9fd�d7�dd�d gdPf�d!gdfgff��d�d"dR�d#�d$�d$g�d�d%gff��ddrdk�d&g�d'��d(�d)gff��ddrd{�d&dʐd*d7�d+�d,�d-gd9fd9fggff��ddrdX�d&d��d.�dd��d/�d0gdfgfggff��d1��d2��d3��d4��d5��dd7dKg�d6�d9ff��dd7�dgd9ff��ddLdFg�d7�d9ff��ddLdKg�d6�d9ff��ddL�dgd9ff��ddrdk�d8�d9ggff�Ze�dS(:�N)�dedent)�supportcCs�|dust|tttf�r|St|t�rdd�|D�S|jjg}t|d�rHt|d�rH|�|j	|j
f�t|d�rHt|d�rH|d|j|jf7<|j
durQt|�S|j
D]}|�tt||���qTt|�S)NcSsg|]}t|��qS�)�to_tuple)�.0�err�$/usr/lib/python3.10/test/test_ast.py�
<listcomp>szto_tuple.<locals>.<listcomp>�lineno�
col_offset�
end_lineno�end_col_offset���)�
isinstance�str�int�complex�list�	__class__�__name__�hasattr�appendr
rrr
�_fields�tupler�getattr)�t�result�frrrrs



r)C�Nonez'module docstring'z
def f(): passzdef f(): 'function docstring'zdef f(a): passzdef f(a=0): passzdef f(*args): passzdef f(**kwargs): passzGdef f(a, b=1, c=None, d=[], e={}, *args, f=42, **kwargs): 'doc for f()'zclass C:passz class C: 'docstring for class C'zclass C(object): passzdef f():return 1zdel v�v = 1za,b = cz	(a,b) = cz	[a,b] = czv += 1zfor v in v:passzwhile v:passz	if v:passzif a:
  pass
elif b:
  passz(if a:
  pass
elif b:
  pass
else:
  passzwith x as y: passzwith x as y, z as q: passzraise Exception('string')z$try:
  pass
except Exception:
  passztry:
  pass
finally:
  passzassert vz
import syszfrom sys import vzglobal v�1�passzfor v in v:breakzfor v in v:continuezfor a,b in c: passzfor (a,b) in c: passzfor [a,b] in c: passzL(
    (
    Aa
    ,
       Bb
    )
    for
    Aa
    ,
    Bb in Cc
    )z"{a : b for w in x for m in p if g}z{a : b for v,w in x}z{r for l in x if g}z{r for l,m in x}z3async def f():
 'async function'
 await something()z,async def f():
 async for e in i: 1
 else: 2z$async def f():
 async with a as b: 1z{**{1:2}, 2:3}z{*{1, 2}, 3}z$async def f():
 [i async for b in c]z'@deco1
@deco2()
@deco3(1)
def f(): passz-@deco1
@deco2()
@deco3(1)
async def f(): passz'@deco1
@deco2()
@deco3(1)
class C: passz!@deco(a for a in b)
def f(): pass�@a.b.c
def f(): passz(a := 1)zdef f(a, /,): passzdef f(a, /, c, d, e): passzdef f(a, /, c, *, d, e): passz'def f(a, /, c, *, d, e, **kwargs): passzdef f(a=1, /,): passzdef f(a=1, /, b=2, c=4): passz def f(a=1, /, b=2, *, c=4): passzdef f(a=1, /, b=2, *, c): passz*def f(a=1, /, b=2, *, c=4, **kwargs): passz(def f(a=1, /, b=2, *, c, **kwargs): passz1+2)#rza and b�a + bznot vzlambda:Nonez{ 1:2 }�{}z{None,}z&{
      1
        :
          2
     }z[a for b in c if d]z(a for b in c if d)z[(a,b) for a,b in c]z[(a,b) for (a,b) in c]z[(a,b) for [a,b] in c]z{(a,b) for a,b in c}z{(a,b) for (a,b) in c}z{(a,b) for [a,b] in c}z((a,b) for a,b in c)z((a,b) for (a,b) in c)z((a,b) for [a,b] in c)z	1 < 2 < 3zf(1,2,c=3,*d,**e)�
f(*[0, 1])zf(a for a in b)�10z'string'�a.bza[b:c]�vz[1,2,3]z[]z1,2,3z(1,2,3)�()za.b.c.d(a.b[1:2])c@s*eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zejd5d6��Zd7d8�Z d9d:�Z!d;d<�Z"d=d>�Z#d?d@�Z$dAdB�Z%dCdD�Z&dEdF�Z'dGS)H�	AST_TestscCs0t|t�sdSd|jvrdS|dko|d��S)NF�ast�ASTr)r�type�
__module__�isupper)�self�name�noderrr�_is_ast_node�s


zAST_Tests._is_ast_nodecCs�t|tj�r|jdur
dSt|tjtjtjf�r*|j|jf}|�	||�|j|jf}|jD]4}t
||�}t|t�rW|}|rK|dkrK|dj|djf}|D]}|�||�qMq-|dura|�||�q-|�
|j|j�dS)N�decorator_listr)rr+r,r�expr�stmt�
excepthandlerr
r�assertGreaterEqualrr�_assertTrueorder�assertEqual�__match_args__)r0�ast_node�
parent_pos�node_posr1�value�	first_pos�childrrrr9s&


��zAST_Tests._assertTrueordercCs�t��}|�|jd�d|_|�|jd�|�|jdd�|�t��|jWd�n1s1wY|�t	��t�d�Wd�dS1sLwYdS)Nr�*�foobar�)
r+r,r:rrC�__dict__�assertRaises�AttributeError�vararg�	TypeError�r0�xrrr�test_AST_objectss�"�zAST_Tests.test_AST_objectscCsLGdd�d�}t��}|�|_||j_t�|j�}~t��|�|��dS)Nc@�eZdZdS)z0AST_Tests.test_AST_garbage_collection.<locals>.XN�rr.�__qualname__rrrr�X%�rP)	r+r,rK�a�weakref�refr�
gc_collect�assertIsNone)r0rPrRrTrrr�test_AST_garbage_collection$sz%AST_Tests.test_AST_garbage_collectionc
Cs�ttdfttdfttdffD]Z\}}}t||�D]O\}}|jd|d��t|d|t	j
�}|�t|�|�|�
|d�Wd�n1sDwY|jd||d	��t|d|�Wd�n1sbwYqqdS)
N�exec�single�eval�parsing)�action�input�?)rr�	compiling)r\r]�kind)�
exec_tests�exec_results�single_tests�single_results�
eval_tests�eval_results�zip�subTest�compiler+�
PyCF_ONLY_ASTr:rr9)r0r]�outputr`�i�o�ast_treerrr�
test_snippets/s ������zAST_Tests.test_snippetscCs0ttt}|D]
}t�|�}t|dd�qdS)N�<string>rX)rarcrer+�parseri)r0�snippets_to_validate�snippet�treerrr�test_ast_validation;s

�zAST_Tests.test_ast_validationcCs<t�d�jdjj}|�|j�|�|j�|�|j�dS)Nzx[::]r)	r+rq�bodyr?�slicerV�upper�lower�step)r0�slcrrr�
test_sliceBszAST_Tests.test_slicecCs t�d�jd}|�|j�dS)Nzfrom . import yr)r+rqrvrV�module)r0�imrrr�test_from_importHszAST_Tests.test_from_importcCs>t�d�}|�|jdtj�d��|jd_t|dd�dS)Nzfrom __future__ import divisionrz __future__ �<test>rX)r+rq�assertIsInstancerv�
ImportFrom�stripr}ri)r0�modrrr�!test_non_interned_future_from_astLs
z+AST_Tests.test_non_interned_future_from_astcCs�t�d�jd}|�t|j�d�|jd}|�|jd�|�|j�|�|j	d�|�|j
d�|�|jd�|�|jd�t�d�jd}|jd}|�|jd�|�|j�|�|j	d�|�|j
d�|�|jd�|�|jd�t�d	�jd}|jd}|�|jd�|�|jd
�|�|j	d�|�|j
d�|�|jd�|�|jd�t�d�jd}|jd}|�|jd
�|�|jd�|�|j	d�|�|j
d�|�|jd�|�|jd�dS)Nzfrom bar import yr��y��zfrom bar import *�*zfrom bar import y as z�z�zimport bar as foo�bar�foo�)
r+rqrvr:�len�namesr1rV�asnamer
rrr
)r0r~�aliasrrr�
test_aliasRsB



zAST_Tests.test_aliascCs||�ttjtj��|�ttjtj��|�ttjtj��|�ttjtj��|�ttjtj��|�ttj	tj��dS�N)
�
assertTrue�
issubclassr+�Forr6�Namer5r,�
comprehension�Gt�r0rrr�test_base_classesxszAST_Tests.test_base_classescCsRtj��D]!\}}|�||�r&|dkrq|�}t|tj�r&|�t|j�t	�qdS)N�Index)
r+rE�itemsr3rr,r:r-rr)r0r1�itemrKrrr�test_field_attr_existence�s��z#AST_Tests.test_field_attr_existencecCs�t��}|�|jd�|�t��|jWd�n1swY|�|j�tjt	dd��}|�|jd�|�|jd�dS)N)�posonlyargs�argsrH�
kwonlyargs�kw_defaults�kwarg�defaultsr��rD�)
r+�	argumentsr:rrFrGr�rVrH�rangerJrrr�test_arguments�s�zAST_Tests.test_argumentscCs t��}d|_|�|jd�dS)Ni�)r+�Numrr:rJrrr�test_field_attr_writable�sz"AST_Tests.test_field_attr_writablecCs�t��}|�|jd�|�t��|jWd�n1swY|�t��|jWd�n1s6wYt�d�}|�|jd�|�|jd�|�t��|jWd�n1sawY|�t��|j	Wd�n1sywYtjdd�}|�|jd�tjddd�}|�|jd�|�|jd�|�|jd�|�|jd�|�t
tjddd�|jt
tjddddd�|�tjddd�jd�|�tjddd�jd�|�
t
d	��tjddd
�Wd�n1s�wY|�
t
d��tjddd�Wd�n	1�swY|�t�d�jd�|�t�d
�jd
�|�t�d�jd�|�t�d�jd�|�t�d�jd�|�t�d�jd�|�t�d�jd�|�t�d�jd�|�t�d�jd�|�t�d
�jd
�|�t�d�jd�|�t�d�jd�|�t�d�jd�|�t�d�jd�|�t�d�jd�|�t�d�jd�|�t�d�jd�dS)N)r?r`rBrD�r
rr�r�)r�z(Num got multiple values for argument 'n'��nz1Constant got multiple values for argument 'value'�r?�@�@�42�42TF.)r+r�r:rrFrGr?r�r
rCrI�Constantr��assertRaisesRegex�Str�s�Bytes�assertIs�NameConstantrJrrr�test_classattrs�sf��
����zAST_Tests.test_classattrscCs�|�tt�d��tj�|�tt�d��tj�|�tt�d��tj�|�tt�d��tj�|�tt�d��tj�|�tt�d��tj�|�tt�d��tj�|�tt�d��tj�|�tt���tj�dS)NrBr�r�r�r�TF)	r:r-r+r�r�r�r�r��Ellipsisr�rrr�
test_realtype�szAST_Tests.test_realtypecCs�|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt��tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt�d�tj��|�	tt��tj��|�	tt��tj��|�	tt��tj��|�	tt��tj��|�	tt��tj��Gd	d
�d
t
�}|�tt�|d��tj��|�	tt�|d��tj��dS)NrBg������@y������@r�r�TF.c@rM)z$AST_Tests.test_isinstance.<locals>.SNrNrrrr�Ssr�)r�rr+r�r�r�r�r�r��assertFalser)r0r�rrr�test_isinstance�sP zAST_Tests.test_isinstancecCs�Gdd�dtj�}Gdd�dtj�}|d�}|�|jd�|�|jd�|�t|�|�|�t||��|�t|tj��|�t||��|�tt�d�|��|dd�}|�|jd�|�t|�|�dS)NcseZdZ�fdd�Z�ZS)z$AST_Tests.test_subclasses.<locals>.Ncst�j|i|��d|_dS)N�spam)�super�__init__r�)r0r��kwargs�rrrr�s
z-AST_Tests.test_subclasses.<locals>.N.__init__)rr.rOr��
__classcell__rrr�r�Nsr�c@rM)z%AST_Tests.test_subclasses.<locals>.N2NrNrrrr�N2rQr�rBr�r�)	r+r�r:r�r�r-r�rr�)r0r�r�r�rrr�test_subclassess
zAST_Tests.test_subclassescCs*t�d�g}t�|g�}|�|j|�dS)NrB)r+r��Moduler:rv)r0rvrKrrr�test_module(szAST_Tests.test_modulec	Cs�t��}|�|jd�d|_|�|jd�t�d�}t�d�}t��}t�|||�}|�|j|�|�|j|�|�|j	|�t�ddd�}|�|jd�|�|jd�|�|j	d�tjddddd�}|�|jd�|�|jd�|�|j	d�|�|j
d�|�ttjdddd�|jttjdddddd�tjddddd	�}|�|jd�|�|jd�|�|j	d�|�|j
d�tjdddd
d�}|�|jd
�dS)N)�left�op�right�r�r�rDrr��)r�r�r�r
rB)�	foobarbaz)
r+�BinOpr:rr�r��Addr�r�r�r
rFrI)r0rK�n1�n3�addoprrr�test_nodeclasses-s:

zAST_Tests.test_nodeclassescCst��}|�|jd�dS)Nr)r+�Subr:rrJrrr�test_no_fieldsYszAST_Tests.test_no_fieldsc		Cs�ddl}|g}zddl}|�|�Wn	tyYnwgd�}|D]$}|D]}dd�tD�D]}|�|�||��}|�t|�t|��q/q&q"dS)Nr)rr�rDcss�|]
}t|ddd�VqdS)r^rXiN)ri)rrlrrr�	<genexpr>is�z*AST_Tests.test_pickling.<locals>.<genexpr>)	�pickle�cPickler�ImportErrorra�loads�dumpsr:r)	r0r��modsr��	protocolsr��protocolr+�ast2rrr�
test_pickling^s"����zAST_Tests.test_picklingcCs�tddd�}t�tjtjdi|��fi|��gg�}|�t��}t|dd�Wd�n1s0wY|�dt	|j
��dS)NrDr��r
rr�rXzbut got <ast.exprr)�dictr+r��Exprr5rFrIri�assertInr�	exception)r0�pos�m�cmrrr�test_invalid_summs(�zAST_Tests.test_invalid_sumc	Csvt�t�t�dt����gg�}t�|�|�t��}t|dd�Wd�n1s+wY|�	dt
|j��dS)NrBr�rXzidentifier must be of type str)r+r�r�r��Load�fix_missing_locationsrFrIrir�rr�)r0r�r�rrr�test_invalid_identifierts 
�z!AST_Tests.test_invalid_identifierc	Csxtddtftddtf�fD],}tjt�|�d�}t�|�|�td��t|dd�Wd�n1s4wYq
dS)Nr�rD�rvzinvalid type in Constant: typer�rZ)	r�	frozensetr+�
Expressionr�r�r�rIri)r0�invalid_constantrrrr�test_invalid_constant{s
����zAST_Tests.test_invalid_constantcCsjt�d�}d|jdjdj_|�t��}t|dd�Wd�n1s%wY|�dt|j	��dS)Nzdef f():
 yield from g()rr�rXzfield 'value' is required)
r+rqrvr?rF�
ValueErrorrir�rr�)r0�empty_yield_fromr�rrr�test_empty_yield_from�s
�zAST_Tests.test_empty_yield_fromcCsTddl}dd�}t�|d|��|�ttjd�Wd�dS1s#wYdS)NrcWsdSr�r�r�rrr�
bad_normalize�sz0AST_Tests.test_issue31592.<locals>.bad_normalize�	normalizeuϕ)�unicodedatar�	swap_attrrFrIr+rq)r0r�r�rrr�test_issue31592�s
"�zAST_Tests.test_issue31592cCsDt�d�}|jdj}|j}|j}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�t�d�}|jdj}|j}|j}|�|jd�|�|jd�|�|jd�|�|j	d	�|�|jd�|�|jd�|�|jd	�|�|j	d	�|�|jd�|�|jd�|�|jd�|�|j	d�dS)
Nz4+5+6+7rr�r�r�z
4+5-\
 6-7r�r�rD)
r+rqrvr?r�r:rr
r
r)r0rt�parent_binop�child_binop�grandchild_binoprrr� test_issue18374_binop_col_offset�s4

z*AST_Tests.test_issue18374_binop_col_offsetcCs.t�d�}|jdjdj}|�|jd�dS)Nr"rr�)r+rqrvr4r?r:r
)r0rt�attr_brrr�*test_issue39579_dotted_name_end_col_offset�s
z4AST_Tests.test_issue39579_dotted_name_end_col_offsetcCs�|�tjjd�|�tjjd�|�tjjd�|�tjjd�dd�tj��D�}dtj��dj��|d<|�	tjj�
d	�|�dS)
Nz0withitem(expr context_expr, expr? optional_vars)�GtEz%Name(identifier id, expr_context ctx)zBcmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIncSsg|]}d|j���qS)z     | )�__doc__)rr2rrrr	�sz5AST_Tests.test_ast_asdl_signature.<locals>.<listcomp>zexpr = r�
)r:r+�withitemr	rr��cmpopr5�__subclasses__�assertCountEqual�split)r0�expressionsrrr�test_ast_asdl_signature�sz!AST_Tests.test_ast_asdl_signaturecCstjddd�tjddd�|�t��tjddd�Wd�n1s%wY|�t��tjddd�Wd�n1sAwYtjddd�tjddd�|�t��tjddd�Wd�n1skwY|�t��tjddd�Wd�dS1s�wYdS)Nzdef foo(x, /): ...�r�r���feature_versionzdef bar(x=1, /): ...�r�r�zlambda x, /: ...zlambda x=1, /: ...�r+rqrF�SyntaxErrorr�rrr�$test_positional_only_feature_version�s ���"�z.AST_Tests.test_positional_only_feature_versioncCsftjddd�tjddd�|�t��tjddd�Wd�n1s%wYtjddd�dS)Nz#with (CtxManager() as example): ...)r��
r)r��	rz!with CtxManager() as example: ...rr�rrr�'test_parenthesized_with_feature_version�s�z1AST_Tests.test_parenthesized_with_feature_versioncC�Ltjddd�|�t��tjddd�Wd�dS1swYdS)Nzf"{x=}"rrrrr�rrr�#test_debug_f_string_feature_version��"�z-AST_Tests.test_debug_f_string_feature_versioncCr)Nz(x := 0)rrrrr�rrr�*test_assignment_expression_feature_version�rz4AST_Tests.test_assignment_expression_feature_versionc	CsndD]2}t�t�|t����}t�|�|�td|�d���t|dd�Wd�n1s/wYqdS)N)�True�Falserz"identifier field can't represent 'z
' constantr�rZ)r+r�r�r�r�r�r�ri)r0�constantr5rrr�test_constant_as_name�s
���zAST_Tests.test_constant_as_nameN)(rr.rOr3r9rLrWrorur|rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�cpython_onlyrrrrrrrrr#rrrrr*�sJ&
</,	
		r*c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�ZdS):�ASTHelpers_TestNcCs6t�d�}tdddtj�}|�t�|�t�|��dS)Nz
foo(1 + 1)z	<unknown>rX)r+rqrirjr:�dump)r0rR�brrr�
test_parse�s
zASTHelpers_Test.test_parsecCsfzddWdSty2|�t��
}t�d�Wd�n1s#wY|�|jj�YdSw)Nr�rz'\U')�	ExceptionrFrr+�literal_eval�assertIsNotNoner��__context__�r0rrrr�test_parse_in_error�s��z#ASTHelpers_Test.test_parse_in_errorcCsLt�d�}|�t�|�d�|�tj|dd�d�|�tj|dd�d�dS)	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=[])�r+rqr:r&�r0r2rrr�	test_dump�s
���zASTHelpers_Test.test_dumpcCsTt�d�}|�tj|dd�d�|�tj|ddd�d�|�tj|d	dd
�d�dS)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�	)r1r8z�Module(
	[
		Expr(
			Call(
				Name('spam', Load()),
				[
					Name('eggs', Load()),
					Constant('and cheese')],
				[]))],
	[])T)r3r8a�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=[])r4r5rrr�test_dump_indents
z ASTHelpers_Test.test_dump_indentcCs�tjddd�}|�t�|�d�|�tj|dd�d�tjtjdt��d	�ddd
�}|�t�|�d�|�tj|dd
�d�|�tj|dd�d�|�tj|ddd�d�tjtjdt��d	�d�}|�t�|�d�|�tj|dd
�d�dS)Nr�r�r�zRaise()Tr2zRaise(lineno=3, col_offset=4)r)�id�ctx)�excr
rz#Raise(exc=Name(id='e', ctx=Load()))Fr0zRaise(Name('e', Load()))z;Raise(exc=Name(id='e', ctx=Load()), lineno=3, col_offset=4))r1r3z0Raise(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�r�r5rrr�test_dump_incompleteNs6��������z$ASTHelpers_Test.test_dump_incompletecCs�tjddd�}t�t�d�|jj�|j_|�tj|dd�d�tjddddd	�}t�|tjddd
��}|�	|j
�|�	|j�|�|jd�|�|j
d�dS)N�1 + 1rZ��moderDTr2z�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))r�)rr
rr
)rr
)r+rq�
copy_locationr�rvr�r:r&�CallrVrr
r
r)r0�src�newrrr�test_copy_locationks�z"ASTHelpers_Test.test_copy_locationcCslt�d�}|j�t�t�t�dt���t�d�gg���|�	|t�
|��d|_|�	tj|dd�d�dS)Nz
write("spam")r��eggsTr2a�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=[]))
r+rqrvrr�rEr�r�r�r:r��maxDiffr&�r0rFrrr�test_fix_missing_locations{s
��z*ASTHelpers_Test.test_fix_missing_locationscCs�tjddd�}|�tj|dd�|�|�tj|dd�d�tjddd�}|�tj|jdd�|j�|�tj|dd�d�tjt�d	t���ggd
d�}|�t�|�j	d�|�
t�|�j�dS)
NrArZrBr�r�Tr2z�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))�testr�)�funcr��keywordsr
rD)r+rqr:�increment_linenor&rvrEr�r�r
rVrrKrrr�test_increment_lineno�s���z%ASTHelpers_Test.test_increment_linenocCs`tjtd�dd�}tj|dd�|�|jdjd�|�|jdjd	�|�|jdjd
�dS)Nzb        a = 1
        b = 2 # type: ignore
        c = 3
        d = 4 # type: ignore@tag
        T)�
type_commentsr�r�rr�r�rz@tag)r+rqrrPr:�type_ignoresr
�tagrKrrr�test_increment_lineno_on_module�s
�z/ASTHelpers_Test.test_increment_lineno_on_modulecCsHtjddd�}tt�|j��}|�|�d�jd�|�|ggd��dS)N�foo()rZrBrNr�)rOr�)r+rqr��iter_fieldsrvr:�popr;)r0r2�drrr�test_iter_fields�sz ASTHelpers_Test.test_iter_fieldscCs�tjddd�}|�ttt�|j���d�t�|j�}|�t|�jd�|�t|�j	d�|�t|�j	d�|�t�
t|��d�dS)	Nzspam(23, 42, eggs='leek')rZrBr�r��rBz1keyword(arg='eggs', value=Constant(value='leek')))r+rqr:r�r�iter_child_nodesrv�nextr;r?r&)r0r2�iteratorrrr�test_iter_child_nodes�s�z%ASTHelpers_Test.test_iter_child_nodescCs�t�d�}|�t�|�d�t�d�}|�t�|jd�d�t�d�}|�t�|jd�d�t�d�}|�t�|jd�d�dS)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
ham)r+rqr:�
get_docstringrvr5rrr�test_get_docstring�s
�
�
�
z"ASTHelpers_Test.test_get_docstringcCs.|�t�t�d���t�d�}|�t�|��t�d�}|�t�|��t�d�}|�t�|jd��t�d�}|�t�|jd��t�d�}|�t�|jd��t�d�}|�t�|jd��t�d�}|�t�|jd��t�d	�}|�t�|jd��t�d
�}|�t�|jd��dS)N�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")rVr+r`rqrvr5rrr�test_get_docstring_none�s&








z'ASTHelpers_Test.test_get_docstring_nonecCst�d�}|�|jdjd�|�|jdjd�|�|jdjdjd�|�|jdjdjd�|�|jdjdjdjd�|�|jdjdjdjd�|�|jdjdjd�|�|jdjdjd�|�|jdjd�|�|jdjd	�dS)
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"""

rr�rDr�r�r��
)r+rqr:rvrr
r5rrr�:test_multi_line_docstring_col_offset_and_lineno_issue16806�s�  zJASTHelpers_Test.test_multi_line_docstring_col_offset_and_lineno_issue16806cC�:t�d�}|jdjd}|�|jd�|�|jd�dS)Nz if a:
    pass
elif b:
    pass
rr��r+rqrv�orelser:r
r�r0r2�	elif_stmtrrr�test_elif_stmt_start_position��
z-ASTHelpers_Test.test_elif_stmt_start_positioncCrg)Nz/if a:
    pass
elif b:
    pass
else:
    pass
rr�rhrjrrr�'test_elif_stmt_start_position_with_elsermz7ASTHelpers_Test.test_elif_stmt_start_position_with_elsecCs<t�d�}|jdjjd}|�|jd�|�|jd�dS)Nr%rr�r)r+rqrvr?r�r:rr
)r0r2�starred_exprrrr�*test_starred_expr_end_position_within_calls
z:ASTHelpers_Test.test_starred_expr_end_position_within_callcCs@|�t�d�gd��|�t�d�ddi�|�t�d�d�|�t�d�hd	��|�t�d
�d�|�t�d�t��|�ttjd
�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�tt�d��d�|�ttjd�|�ttjd�|�ttjd�dS)Nz	[1, 2, 3]�r�rDr�z{"foo": 42}r�rBz(True, False, None))TFNz	{1, 2, 3}>r�rDr�zb"hi"shizset()rV�6�z+6z-6i����z3.25g
@z+3.25z-3.25g
�z-0.0z++6z+Truez2+3)r:r+r*�setrFr��reprr�rrr�test_literal_evals"z!ASTHelpers_Test.test_literal_evalc	Cs�t�d��:t�d�|�t��
}t�d�Wd�n1s wY|�dt|j��|�dt|j��Wd�dS1sBwYdS)Ni���3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333��33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333zExceeds the limit z Consider hexadecimal )	r�adjust_int_max_str_digitsr+r*rFrr�rr�)r0�err_ctxrrr�test_literal_eval_str_int_limit$s
�"�z/ASTHelpers_Test.test_literal_eval_str_int_limitcCs>|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d	�d
�|�t�d�d�|�t�d
�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d
�|�ttjd�|�ttjd�|�ttjd�|�ttjd�|�ttjd�dS)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:r+r*rFr�r�rrr�test_literal_eval_complex,s$z)ASTHelpers_Test.test_literal_eval_complexcCsptjt�d�t�d�gt�d�gd�}|�ttj|�tjt�d�gt�d�t�d�gd�}|�ttj|�dS)Nr�rDr�)�keys�values)r+�Dictr�rFr�r*)r0�	malformedrrr�&test_literal_eval_malformed_dict_nodesAs&&z6ASTHelpers_Test.test_literal_eval_malformed_dict_nodescCsJ|�t�d�d�|�t�d�d�|�t�d�d�|�ttjd�dS)Nz    -1rz		-1z 	 -1z
 -1)r:r+r*rF�IndentationErrorr�rrr�test_literal_eval_trailing_wsGsz-ASTHelpers_Test.test_literal_eval_trailing_wsc	Cs�d}|�t|��
t�d�Wd�n1swYt�t��t�t��t�d���}|�t|dd��d}|�t|��t�|�Wd�dS1sPwYdS)Nz#malformed node or string on line 3:z{'a': 1,
'b':2,
'c':++3,
'd':4}rsr
zmalformed node or string:)	r�r�r+r*�UnaryOp�UAddr�rVr)r0�msgr2rrr�"test_literal_eval_malformed_linenoMs��"�z2ASTHelpers_Test.test_literal_eval_malformed_linenocCs<|�td��t�d�Wd�dS1swYdS)Nzunexpected indentz4
                \
                (\
            \ )r�rr+r*r�rrr�test_literal_eval_syntax_errorsYs"�z/ASTHelpers_Test.test_literal_eval_syntax_errorscCsxtjdtjdd�gdddd�g}t�|g�}|�t��}t|dd�Wd�n1s,wY|�dt|j	��dS)N�time�sleep�r1�r}r��levelr
rrMrXzinvalid integer value: None)
r+r�r�r�rFr�rir�rr�)r0rvr�r�rrr�test_bad_integer`s��z ASTHelpers_Test.test_bad_integercCsZtjdtjdddd�gdddd�g}t�|g�}t|dd�}i}t||�|�d|�dS)Nr�r�r)r1r
rr�rMrX)r+r�r�r�rirXr�)r0rvr��code�nsrrr�test_level_as_noneks��
z"ASTHelpers_Test.test_level_as_nonec	Cs�tjt��ddd�}||_|�t��.t���tt�	|�dd�Wd�n1s+wYWd�dSWd�dS1sCwYdS�Nr)r�r
rr�rZ�
r+r��Not�operandrF�RecursionErrorr�infinite_recursionrir�r-rrr�test_recursion_directws
��"�z%ASTHelpers_Test.test_recursion_directc	Cs�tjt��ddd�}tjt��ddd�}||_||_|�t��.t���tt�	|�dd�Wd�n1s8wYWd�dSWd�dS1sPwYdSr�r�)r0rrrrr�test_recursion_indirect~s
��"�z'ASTHelpers_Test.test_recursion_indirect) rr.rOrJr(r.r6r:r@rHrLrQrUrZr_rarcrfrlrnrprvr{r}r�r�r�r�r�r�r�r�rrrrr%�s<=r%c@s�eZdZdted�dd�Zdued�dd�Zdudd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&dJdK�Z'dLdM�Z(dNdO�Z)dPdQ�Z*dRdS�Z+dTdU�Z,dVdW�Z-dXdY�Z.dZd[�Z/d\d]�Z0d^d_�Z1e2�3d`�Z4e2�5e4�Z6e2�3da�Z7e2�5e7�Z8e2�3db�Z9e2�:db�Z;e2�<dce2�=��Z>e2�5e2�?e2�?e2�<dae2�@��dde2�=��dee2�=���e2�5e2�?e2�?e2�<dae2�=��dde2�@��dee2�=���e2�5e2�3df��e2�5e2�3db��e2�5e2�3dg��e2�:dh�e2�Ae2�:dh�g�e2�Ae2�Ae2�:dh�g�g�e2�Be4e9ge8g�e2jBe9e4ge8e6gdidj�e2jBe9e2�Ce2�<dke2�=��e2�=��ge8e6gdldj�e2jDe2�?e2�?e7dde2�=��dee2�=��gggdm�e2jDe>gdige6gdm�e2jDe>gge6gdm�e2jDe>e2�:dh�gggdm�e2jDe>e2�E�gggdm�e2jDe>gge2�E�gdm�e2�Ae2�Edi�g�e2jFdndo�e2�Gg�e2�Ge6g�e2�Ge6e8e2�:dp�g�e2jFdqdo�e2jEdado�e2�Ae2�Edq�g�e2jBggdqdj�gZHdrds�ZIdS)v�ASTValidatorTestsNrX�r=cCszd|_|_t�|�|durt|d|�dS|�|��}t|d|�Wd�n1s-wY|�|t|j��dS)Nrr�)	r
rr+r�rirFr�rr�)r0r�r�rCr=r�rrrr��s
�zASTValidatorTests.modcCs(t�t�|�gg�}|j|||d�dS)Nr�)r+r�r�r�)r0r2r�r=r�rrrr5�szASTValidatorTests.exprcCst�|gg�}|�||�dSr�)r+r�r�)r0r6r�r�rrrr6�szASTValidatorTests.stmtc	CsTt�t�t�dt����g�}|�|dd�t�t�dt����}|�|dd�dS)NrK�must have Load contextrYrZ)r+�Interactiver�r��Storer�r�)r0r�rrrr��szASTValidatorTests.test_modulec	s			d�fdd�	}t�dt�dt����g}|||d�d�|||d�d�|||d�d�||t�d�gd	�d
�||t�d�gd�d
�t�dt�dt����g}|||t�dt���gd�d�t�dt�dt����t�dt�dt����g}|||dt�dt���gd�d�dS)Nc	sZ|durg}|durg}|durg}|durg}|durg}t�|||||||�}�|�Sr�)r+r�)r�r�rHr�r�r�r���facrrr��s�z5ASTValidatorTests._check_arguments.<locals>.argumentsrKr�r�)r�)r�r�)r�z"more positional defaults than argsr�)r�z3length of kwonlyargs is not the same as kw_defaults)r�r�rRr'r�)r�r�)NNNNNNN)r+�argr�r�r�r�)r0r��checkr�r�rr�r�_check_arguments�s4�������z"ASTValidatorTests._check_argumentscCs�t�ggdggdg�}t�d|ggd�}|�|d�t�d|t��gt�dt���gd�}|�|d�t�d|t��ggt�dt����}|�|d�dd�}|�||j�dS)NrKzempty body on FunctionDefr�cSst�d|t��ggd�S�NrK)r+�FunctionDef�Passr�rrrr���z+ASTValidatorTests.test_funcdef.<locals>.fac)r+r�r�r6r�r�r�r�)r0rRrr�rrr�test_funcdef�s ��zASTValidatorTests.test_funcdefcCs�ddd�}|�|t�dt���gd�d�|�|t�dt�dt����gd�d�|�|gd�d�|�|dgd�d	�|�|t�dt���gd
�d�dS)NcSsH|durg}|durg}|durt��g}|durg}t�d||||�S)N�myclass)r+r��ClassDef)�basesrOrvr4rrr�cls�s

�z,ASTValidatorTests.test_classdef.<locals>.clsrK)r�r�)rOr�zempty body on ClassDef�None disallowed)r4)NNNN)r6r+r�r��keyword)r0r�rrr�
test_classdef�s
�"��zASTValidatorTests.test_classdefc	CsJ|�t�g�d�|�t�dg�d�|�t�t�dt���g�d�dS)Nzempty targets on Deleter�rKzmust have Del context)r6r+�Deleter�r�r�rrr�test_delete�s
�zASTValidatorTests.test_deletec
Cs�|�t�gt�d��d�|�t�dgt�d��d�|�t�t�dt���gt�d��d�|�t�t�dt���gt�dt����d�dS)Nr�zempty targets on Assignr�rK�must have Store contextr�r�)r6r+�Assignr�r�r�r�r�rrr�test_assign�s"���zASTValidatorTests.test_assignc	Cspt�t�dt���t��t�dt����}|�|d�t�t�dt���t��t�dt����}|�|d�dS)NrKr�r�r�)r+�	AugAssignr�r�r�r6r�)r0�augrrr�test_augassign�s��z ASTValidatorTests.test_augassignc
Cs�t�dt���}t�dt���}t��}|�t�||gg�d�|�t�t�dt���||gg�d�|�t�|t�dt���|gg�d�t�t�dt����}|�t�|||gg�d�|�t�|||g|g�d�dS)NrKr�zempty body on Forr�r�)r+r�r�r�r�r6r�r�)r0rKr��prrrr�test_for�s � � zASTValidatorTests.test_forc
Cs~|�t�t�d�gg�d�|�t�t�dt���t��gg�d�|�t�t�d�t��gt�t�dt����g�d�dS)Nr�zempty body on WhilerKr�)r6r+�Whiler�r�r�r�r�r�rrr�
test_whiles"���zASTValidatorTests.test_whilecCs�|�t�t�d�gg�d�t�t�dt���t��gg�}|�|d�t�t�d�t�t�dt����gg�}|�|d�t�t�d�t��gt�t�dt����g�}|�|d�dS)Nr�zempty body on IfrKr�)r6r+�Ifr�r�r�r�r�)r0rlrrr�test_ifs (�zASTValidatorTests.test_ifcCs�t��}|�t�g|g�d�t�t�d�d�}|�t�|gg�d�t�t�dt���d�}|�t�|g|g�d�t�t�d�t�dt����}|�t�|g|g�d�dS)Nzempty items on Withr�zempty body on WithrKr�r�)	r+r�r6�Withrr�r�r�r�)r0r�rlrrr�	test_withszASTValidatorTests.test_withcCspt�dt�d��}|�|d�t�t�dt���d�}|�|d�t�t�d�t�dt����}|�|d�dS)Nr�z!Raise with cause but no exceptionrKr�r�)r+r?r�r6r�r�)r0�rrrr�
test_raise'szASTValidatorTests.test_raisecCsxt��}t�ggg|g�}|�|d�t�t�t�dt����ggg|g�}|�|d�t�|gggg�}|�|d�t�|gg|g|g�}|�|d�t�|gt�ddg�ggg�}|�|d�t�t�dt���d|g�g}|�t�|g|gg�d�t�dd|g�g}t�|g|t�t�dt����g|g�}|�|d�t�|g||gt�t�dt����g�}|�|d�dS)Nzempty body on TryrKr�z-Try has neither except handlers nor finalbodyz%Try has orelse but no except handlerszempty body on ExceptHandlerr�)r+r��Tryr6r�r�r��
ExceptHandler)r0r�rrrrr�test_try/s$&((zASTValidatorTests.test_tryc	CsT|�t�t�dt���d�d�t�t�dt���t�dt����}|�|d�dS)NrKr�r�)r6r+�Assertr�r�r�)r0�assrtrrr�test_assertCs��zASTValidatorTests.test_assertcC�|�t�g�d�dS)Nzempty names on Import)r6r+�Importr�rrr�test_importJ�zASTValidatorTests.test_importcCs>t�dt�dd�gd�}|�|d�|�t�dgd�d�dS)NrKi���zNegative ImportFrom levelrzempty names on ImportFrom)r+r�r�r6)r0�imprrr�test_importfromMsz!ASTValidatorTests.test_importfromcCr�)Nzempty names on Global)r6r+�Globalr�rrr�test_globalRr�zASTValidatorTests.test_globalcCr�)Nzempty names on Nonlocal)r6r+�Nonlocalr�rrr�
test_nonlocalUr�zASTValidatorTests.test_nonlocalcCs&t�t�dt����}|�|d�dS�NrKr�)r+r�r�r�r6r-rrr�	test_exprXszASTValidatorTests.test_exprc	Cs�t�t��g�}|�|d�t�t��t�d�g�}|�|d�t�t��t�d�dg�}|�|d�t�t��t�d�t�dt���g�}|�|d�dS)Nzless than 2 valuesr�r�r�rKr�)r+�BoolOp�Andr5r�r�r�)r0r'rrr�test_boolop\s&zASTValidatorTests.test_boolopcCs,t�t��t�dt����}|�|d�dSr�)r+r�r�r�r�r5)r0�urrr�test_unaryopfszASTValidatorTests.test_unaryopc
CsPt�ggdggdg�}|�t�|t�dt����d�dd�}|�||j�dS)NrKr�cSst�|t�dt����Sr�)r+�Lambdar�r�r�rrrr�nr�z*ASTValidatorTests.test_lambda.<locals>.fac)r+r�r5r�r�r�r�)r0rRr�rrr�test_lambdajs�zASTValidatorTests.test_lambdacCsXt�dt���}t�dt���}|||f|||f|||ffD]}|�tj|�d�qdS�NrKr�r�)r+r�r�r�r5�IfExp)r0�lr�r�rrr�
test_ifexprs
 �zASTValidatorTests.test_ifexpcCsRt�gt�dt���g�}|�|d�t�t�dt���gdg�}|�|d�dS)NrKzsame number of keys as valuesr�)r+r�r�r�r5)r0rYrrr�	test_dictxszASTValidatorTests.test_dictcCs<|�t�dg�d�t�t�dt���g�}|�|d�dS�Nr�rKr�)r5r+�Setr�r��r0r�rrr�test_set~szASTValidatorTests.test_setc	Cs�|�|g�d�t�t�dt���t�dt���gd�}|�||g�d�t�t�dt���t�dt���gd�}|�||g�d�t�dt���}t�dt���}t�||dgd�}|�||g�d�t�||t�dt���gd�}|�||g�d�dS)Nz comprehension with no generatorsrKrr�r�r�r�)r5r+r�r�r�r�)r0r��grKr�rrr�_check_comprehension�s��z&ASTValidatorTests._check_comprehensioncsbt�t�dt���t�dt���gd�}|��t�dt���|g�d��fdd�}|�|�dS)NrKrr�cs�t�dt���|�Sr�)r+r�r�)�gensr�rr�wrap�r�z,ASTValidatorTests._simple_comp.<locals>.wrap)r+r�r�r�r�r5r�)r0r�r�r�rr�r�_simple_comp�s��zASTValidatorTests._simple_compcC�|�tj�dSr�)r�r+�ListCompr�rrr�
test_listcomp��zASTValidatorTests.test_listcompcCr�r�)r�r+�SetCompr�rrr�test_setcomp�r�zASTValidatorTests.test_setcompcCr�r�)r�r+�GeneratorExpr�rrr�test_generatorexp�r�z#ASTValidatorTests.test_generatorexpcCs�t�t�dt���t�dt���gd�}t�t�dt���t�dt���|g�}|�|d�t�t�dt���t�dt���|g�}|�|d�dd�}|�|�dS)Nr�r�rrKr�cSs.t�dt���}t�dt���}t�|||�S)NrKr�)r+r�r��DictComp)�comps�kr(rrr�factory�sz0ASTValidatorTests.test_dictcomp.<locals>.factory)r+r�r�r�r�r�r5r�)r0r��cr�rrr�
test_dictcomp�s���zASTValidatorTests.test_dictcompc	Cs@|�t�t�dt����d�|�t�t�dt����d�dS)NrKzmust have Load)r5r+�Yieldr�r��	YieldFromr�rrr�
test_yield�s"zASTValidatorTests.test_yieldcCs�t�dt���}t�|t��gg�}|�|d�t�|t��gt�d�t�d�g�}|�|d�t�t�d�t��g|g�}|�|�t�|t��gt�d�g�}|�|�dS)NrKzno comparatorsr�r�z,different number of comparators and operands�blah)r+r�r��Compare�Inr5r�)r0r��comprrr�test_compare�s$
zASTValidatorTests.test_comparecCs�t�dt���}t�dt���g}t�dt�dt����g}t�t�dt���||�}|�|d�t�|dg|�}|�|d�t�dt�dt����g}t�|||�}|�|d�dS)NrKr��wr�r�r�)r+r�r�r�rEr�r5)r0rNr�rO�call�bad_keywordsrrr�	test_call�szASTValidatorTests.test_callcCszGdd�dt�}Gdd�dt�}Gdd�dt�}dD]
}|�t�|��q|�|�|�fD]
}|jt�|�dtd	�q-dS)
Nc@rM)z*ASTValidatorTests.test_num.<locals>.subintNrNrrrr�subint�rQrc@rM)z,ASTValidatorTests.test_num.<locals>.subfloatNrNrrrr�subfloat�rQrc@rM)z.ASTValidatorTests.test_num.<locals>.subcomplexNrNrrrr�
subcomplex�rQr)�0�hellozinvalid typer�)r�floatrr5r+r�rI)r0rrr�objrrr�test_num�s�zASTValidatorTests.test_numcCs.t�t�dt���dt���}|�|d�dSr�)r+�	Attributer�r�r�r5)r0�attrrrr�test_attribute�sz ASTValidatorTests.test_attributec	Cst�t�dt���t�d�t���}|�|d�t�dt���}t�|t�dt���t���}|�|d�t�dt���}|ddfd|dfdd|ffD]}tj|�}|�t�||t���d�qKt�gt���}|�t�||t����t�|gt���}|�t�||t���d�dS)NrKr�r�r�)	r+�	Subscriptr�r�r�r�r5�Slice�Tuple)r0�subrKr�r��slrrr�test_subscript�s&�� 
�z ASTValidatorTests.test_subscriptc	CsNt�t�t�dt���t���gt���}t�|gt�d��}|�|d�dS)NrKr�r�)	r+�List�Starredr�r�r�r�r�r6)r0r��assignrrr�test_starred�s
 �zASTValidatorTests.test_starredcCs@|�|dgt���d�|�|t�dt���gt���d�dSr�)r5r+r�r�r�)r0r�rrr�	_sequence�s�zASTValidatorTests._sequencecCr�r�)rr+rr�rrr�	test_list�r�zASTValidatorTests.test_listcCr�r�)rr+rr�rrr�
test_tuple�r�zASTValidatorTests.test_tuplecCs|�t�d��dS)Nr�)r5r+r�r�rrr�test_nameconstantsz#ASTValidatorTests.test_nameconstantc
Cs�tj�tj�}dd�t�|�D�}|�ddg�|D]E}|�|��6tj�||�}t	|ddd��}|�
�}Wd�n1s?wYt�||�}t||d�Wd�n1sZwYqdS)	NcSsg|]	}|�d�r|�qS)z.py)�endswith)r�fnrrrr	sz;ASTValidatorTests.test_stdlib_validates.<locals>.<listcomp>ztest/test_grammar.pyztest/test_unpack_ex.pyr�zutf-8)�encodingrX)
�os�path�dirnamer+�__file__�listdir�extendrh�join�open�readrqri)r0�stdlib�testsr}r�fp�sourcer�rrr�test_stdlib_validatess
����z'ASTValidatorTests.test_stdlib_validatesr�rKT�carterr�r�.rq�stringr )�rest�lol�legit)�patterns�	kwd_attrs�kwd_patternsr!r��xxx�_c
Cs�t�dt���}|jD]S}|�tj|dd���?tj|tj|t��gd�gd�}t�	|�}t�
|gg�}|�t��t
|dd�Wd�n1sJwYWd�n1sYwYqdS)NrKr�r7)�patternrv)�subject�casesr�rX)r+r�r��_MATCH_PATTERNSrhr&�Match�
match_caser�r�r�rFr�ri)r0�name_xr8r2r}rrr�test_match_validation_pattern�s(
���
	�����z/ASTValidatorTests.test_match_validation_pattern)NrXr�)Jrr.rOr�r�r5r6r�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�r�rrrrrrrrrr-r+r��
constant_1�
MatchValue�	pattern_1�
constant_x�	pattern_x�
constant_true�MatchSingleton�pattern_truer�r��name_carterrr��
MatchSequence�MatchMappingr�
MatchClass�	MatchStar�MatchAs�MatchOrr;r?rrrrr��sP

"	



	





���	���	��������	��������
���������

�tr�c@sfeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ejdd��Z
dd�Zdd�ZdS)�
ConstantTestsz$Tests on the ast.Constant node type.cCs\t�d�}|jdj}tj|d�}t�||�||jd_t|dd�}i}t||�|dS)Nzx = 123rr�rprXrK)r+rqrvr?r�rDrirX)r0r?rtr2�new_noder�r�rrr�compile_constant�s

zConstantTests.compile_constantcCsN|�t��}|�gd��Wd�n1swY|�t|j�d�dS)Nrqz%got an invalid type in Constant: list)rFrIrQr:rr�)r0r�rrr�test_validation�s��zConstantTests.test_validationc	Cs^dddtdt�fD]#}|j|d��|�|�}|�||�Wd�n1s'wYq	dS)NFT�)�const)r�r�rhrQr�)r0rTr?rrr�test_singletons�s
���zConstantTests.test_singletonsc	Cs�d}tdh�}td�D]}|df}t|dh�}qddddd	td
�td�||f	}|D]#}|j|d��|�|�}|�||�Wd�n1sGwYq)dS)
N)r�r�r�rD�{g�^@y�^@�unicode�bytesrr�r�)r�r�rrhrQr:)r0�nested_tuple�nested_frozensetr�rr?rrrr�test_values�s"
�
���zConstantTests.test_valuescCs�t�d�}|jdjd}tjdd�}t�||�||jdjd<|�t��}t|dd�Wd�n1s7wY|�	t
|j�d�dS)N�x = 1rr�r�r/rXz6expression which can't be assigned to in Store context)r+rqrv�targetsr�rDrFr�rir:rr�)r0rt�target�
new_targetr�rrr�test_assign_to_constant�s
��z%ConstantTests.test_assign_to_constantcCs t�d�}|�t�|�d�dS)Nz'docstring'
x = 1�	docstring)r+rqr:r`)r0rtrrrra�s
z ConstantTests.test_get_docstringcCs:t|dd�}g}t�|�D]
}|jdkr|�|j�q
|S)NrprX�
LOAD_CONST)ri�dis�get_instructions�opnamer�argval)r0rt�co�consts�instrrrr�get_load_const�s
�zConstantTests.get_load_constcCs�gd�}d�dd�|D��}|d7}|�tdf�t�|�}|�|�|�|�t|j|�D]!\}}t	|tj
�s>Jt�|���tj|d�}t�
||j�||_q-|�|�|�|�dS)N)	NTF�|g@y@rWrXrqr
cSsg|]}d�|��qS)zx={!r})�format)rrTrrrr	��z1ConstantTests.test_load_const.<locals>.<listcomp>z
x = ...r�)r&r%r�r+rqr:rjrgrvrr�r&r�rDr?)r0rhr�rtrrTrPrrr�test_load_const�s 	
��zConstantTests.test_load_constcCslt�d�}|jdj}tjdd�}t�||j�||_tjdd�}t�||j�||_|�t�	|�d�dS)Nz1 + 2rrr�y4@y$@4@)
r+rqrvr?r�rDr�r�r:r*)r0rt�binop�new_left�	new_rightrrrrvs
zConstantTests.test_literal_evalcCs�tjddd�j}|�|jd�|�|jd�tjddd�j}|�|jd�|�|jd�tjddd�j}|�|jd�|�|jd�tjddd�j}|�|jd	�|�|jd�dS)
Nz"x"rZrBrKzu"x"r�zr"x"zb"x"�x)r+rqrvr:r?r`)r0r�rrr�test_string_kindszConstantTests.test_string_kindN)rr.rOr	rQrRrUr[r`rarjrr$rnrvrsrrrrrO�s

rOc@seZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>S)?�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.
    cCs |�|j|�|�|j|�dSr�)r:rr
)r0r<rr
rrr�_check_end_pos-szEndPositionTests._check_end_poscCs|�t�||�|�dSr�)r:r+�get_source_segment)r0r,r<�contentrrr�_check_content1r�zEndPositionTests._check_contentcCst�|�jdjS)Nr)r+rqrvr?r�rrr�_parse_value4szEndPositionTests._parse_valuecCsJd}|�|�}|�||jd�|�||jjdd�|�||jjd�dS)Nzlambda x, *y: NonerrrKr�)ryrxrvr�rH)r0r��lamrrrr�9s

zEndPositionTests.test_lambdacCs�td���}t�|�jd}|�|dd�|�||jdd�|�||jjdd�|�||jjdjd�|�||jj	d�|�||jj	jd	�dS)
Nz�
            def func(x: int,
                     *args: str,
                     z: float = 0,
                     **kwargs: Any) -> bool:
                return True
            rr��zreturn Truezx: intrzkwargs: Any�Any)
rr�r+rqrvrurxr��
annotationr��r0r��fdefrrr�
test_func_def@s�zEndPositionTests.test_func_defcCsNd}|�|�}|�||jd�|�||jdjd�|�||jdjd�dS)Nzfunc(x, y=2, **kw)rNr�2r��kw)ryrxrNrOr?�r0r�rrrrrPs

zEndPositionTests.test_callcCs0d}|�|�}|�||jd�|�|dd�dS)Nzx[0]()zx[0]r�rs)ryrxrNrur�rrr�test_call_noargsWs
z!EndPositionTests.test_call_noargscCsVtd���}t�|�jd}|�|dd�|�||jdd�|�||jdd�dS)Nz?
            class C(A, B):
                x: int = 0
        rrD�r��Bz
x: int = 0)rr�r+rqrvrurxr��r0r��cdefrrr�test_class_def]s�zEndPositionTests.test_class_defcCs.d}t�|�jd}|�||jdjd�dS)Nz$class S(metaclass=abc.ABCMeta): passrzabc.ABCMeta)r+rqrvrxrOr?r�rrr�
test_class_kwgszEndPositionTests.test_class_kwcC�>td���}t�|�jd}|�|dd�|�|jdd�dS)Nzh
            x = """Some multi-line text.

            It goes on starting from same indent."""
        rr��(�rr�r+rqrvrur?�r0r�rrrr�test_multi_line_strls�z$EndPositionTests.test_multi_line_strcCr�)NzB
            x = "first part" \
            "second part"
        rrDrer�r�rrr�test_continued_strvs�z#EndPositionTests.test_continued_strcCstd���}t�|�}|jd}|jd}|jd}|jd}|jd}|�|dd�|�|dd	�|�|d	d
�|�|dd�|�|dd�|�||jd
�|�||jdd�|�||jdjd�|�||j	d�|�||jdd�|�||j
djd�dS)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
        rr�rDr�r�r�r�r{r��r zx = Nonezother()�x, yzraise RuntimeErrorrI)rr�r+rqrvrurxrMrir^�handlersr-)r0r�r��
while_loop�if_stmt�for_loop�try_stmt�	pass_stmtrrr�test_suitess(�





zEndPositionTests.test_suitescCs,d}|�|�}|jdj}|�||d�dS)Nzx = f"abc {x + y} abc"r�zx + y)ryrr?rx�r0r��fstrrorrr�test_fstring�s
zEndPositionTests.test_fstringcCsTtd���}|�|�}|jdj}|�|dd�|�||jd�|�||jd�dS)Nz�
            f"""Some multi-line text.
            {
            arg_one
            +
            arg_two
            }
            It goes on..."""
        r�r�r��arg_one�arg_two)	rr�ryrr?rurxr�r�r�rrr�test_fstring_multi_line�s�
	z(EndPositionTests.test_fstring_multi_linecCsBtd���}t�|�jd}|�|dd�|�|jddd�dS)NzT
            from x.y.z import (
                a, b, c as c
            )
        rr�r�rDr�)rr�r+rqrvrur�)r0r�r�rrr�test_import_from_multi_line�s�z,EndPositionTests.test_import_from_multi_linecCs�d}d}td���}t|j|||f�\}}}|�||jd�|�||jjd�|�||jjd�|�||jjd�|�||jj	djd	�|�||jj	d
jd�|�
|dd�dS)
Nz
f()[1, 2] [0]zx[ a.b: c.d]zN
            x[ a.b: f () ,
               g () : c.d
              ]
        z	f()[1, 2]z1, 2r'zc.dr�f ()r��g ()r�)rr��mapryrxr?rwryrx�eltsru)r0�s1�s2�sm�i1�i2r~rrr�test_slices�s�zEndPositionTests.test_slicescCsZtd���}|�|�}|�|dd�|�||jd�|�||jd�|�||jjd�dS)NzF
            (1 * 2 + (3 ) +
                 4
            )
        rDrs�4z1 * 2 + (3 )�3)rr�ryrurxr�r�)r0r�rorrr�
test_binop�s�
zEndPositionTests.test_binopcCsDtd���}t�|�jdj}|�|dd�|�||jdd�dS)Nz{
            if (one_condition and
                    (other_condition or yet_another_one)):
                pass
        rrD�,r�z"other_condition or yet_another_one)	rr�r+rqrvrMrurxr)r0r��boprrrr��s��zEndPositionTests.test_boolopc	Cspd}d}d}td���}t|j||||f�\}}}}|�||d�|�||d�|�||d�|�|dd	�dS)
Nzx = () ;z	x = 1 , ;zx = (1 , 2 ) ;z?
            x = (
                a, b,
            )
        r)z1 ,z(1 , 2 )r�r�)rr�r�ryrxru)	r0r�r��s3r��t1�t2�t3�tmrrr�test_tuples�s�zEndPositionTests.test_tuplescCs4d}|�|�}|�|||�|�||jdd�dS)Nz
func(x. y .z)rzx. y .z)ryrxr�r�rrr�test_attribute_spacess
z&EndPositionTests.test_attribute_spacescCsvd}t�|�jdj}|�t|�jd�|�||d�d|}t�|�jdjj}|�t|�jd�|�||d�dS)Nz( ( ( a + b ) ) )rr�r#�await )r+rqrvr?r:r-rrx)r0r�r(r�rrr�test_redundant_parenthesissz+EndPositionTests.test_redundant_parenthesisc	Cs�d}|D]P\}}|�|��?t�|�jdj}|�t|�j|�|�|||�d|}t�|�jdjj}|�t|�j|�|�|||�Wd�n1sOwYqdS)N))z( ( ( a ) ) ) ( )rE)z( ( ( a ) ) ) ( b )rE)z( ( ( a ) ) ) [ b ]r)z( ( ( a ) ) ) . brrr�)	rhr+rqrvr?r:r-rrx)r0r*r�rr(r�rrr�(test_trailers_with_redundant_parenthesiss���z9EndPositionTests.test_trailers_with_redundant_parenthesiscCs�d}d}|�|�}|�|�}|�||jdd�|�||jdd�|�||jdd�|�||jdd	�|�||jdd
�dS)Nz[{}, {1, }, {1, 2,} ]z{a: b, f (): g () ,}rr$r�z{1, }rDz{1, 2,}r�r�)ryrxr�r~r)r0r�r��c1�c2rrr�
test_displays#s

zEndPositionTests.test_displayscCs�td���}|�|�}|�|dd�|�||jdjd�|�||jjdjd�|�||jjdjdd�|�||jjdj	d�dS)	Nza
            x = [{x for x, y in stuff
                  if cond.x} for stuff in things]
        rD�%r�things�stuffzcond.xr�)
rr�ryrurx�
generators�iter�elt�ifsr^)r0r��cmprrr�test_comprehensions.s�
z$EndPositionTests.test_comprehensionscCsLtd���}t�|�jd}|�||jdjd�|�||jdjd�dS)NzT
            async def f():
                yield x
                await y
        rzyield xr�zawait y)rr�r+rqrvrxr?r~rrr�test_yield_await:s�z!EndPositionTests.test_yield_awaitcCs<td���}td���}|�|�}|�t�||j�|�dS)NzD
            x = (
                a, b,
            ) + ()
        z;
            (
                a, b,
            )
        )rr�ryr:r+rvr�)r0�s_orig�s_tuplerorrr�test_source_segment_multiDs��
z*EndPositionTests.test_source_segment_multicC�Btd���}d}t�|�jd}|�tj||jddd�|�dS)Nuf
            class C:
                def fun(self) -> None:
                    "ЖЖЖЖЖ"
        u/    def fun(self) -> None:
        "ЖЖЖЖЖ"rT��padded�rr�r+rqrvr:rv)r0r��s_methodr�rrr�test_source_segment_paddedRs��z+EndPositionTests.test_source_segment_paddedcCsdd}t�|�j\}}}}}|�||d�|�||d�|�||d�|�||d�|�||d�dS)Nz!v = 1
w = 1
x = 1

y = 1
z = 1
rzw = 1r\zy = 1zz = 1)r+rqrvrx)r0r�r(rrKr�r�rrr�test_source_segment_endings^sz,EndPositionTests.test_source_segment_endingscCr�)Nzb
            class C:
              	  def fun(self) -> None:
              	      pass
        z+  	  def fun(self) -> None:
  	      passrTr�r�)r0r�r�r�rrr�test_source_segment_tabsgs�"z)EndPositionTests.test_source_segment_tabscCstd}t�|�j\}}}}|`|`|`|`|�t�||��|�t�||��|�t�||��|�t�||��dS)Nzv = 1
w = 1
x = 1

y = 1
)	r+rqrvr
rrr
rVrv)r0r�r(rrKr�rrr� test_source_segment_missing_infossz1EndPositionTests.test_source_segment_missing_infoN)"rr.rOr	rurxryr�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrt's@

	,


	rtc@seZdZdd�ZdS)�NodeVisitorTestscs�G�fdd�dtj�}t�td��}|�}g�tjdd��}t�ddt�|�|�Wd�n1s4wY|�	�gd��|�	d	d
�|D�gd��dS)NcsHeZdZ�fdd�Z�fdd�Z�fdd�Z�fdd�Z�fd	d
�ZdS)z9NodeVisitorTests.test_old_constant_nodes.<locals>.Visitorc���|jd|jf�dS)Nr�)rr
r�r5��logrr�	visit_Num�r�zCNodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_Numcr�)Nr��rr
r�r5r�rr�	visit_Str�r�zCNodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_Strcr�)Nr�r�r5r�rr�visit_Bytes�r�zENodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_Bytescr�)Nr�)rr
r?r5r�rr�visit_NameConstant�r�zLNodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_NameConstantcs��|jddf�dS)Nr�.)rr
r5r�rr�visit_Ellipsis�r�zHNodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_EllipsisN)rr.rOr�r�r�r�r�rr�rr�Visitor�sr�z�            i = 42
            f = 4.25
            c = 4.25j
            s = 'string'
            b = b'bytes'
            t = True
            n = None
            e = ...
            T)�record�alwaysrb))r�r�rB)rDr�r�)r�r�r�)r�r�r/)r�r�rX)rsr�T)r�r�N)r�r�.cSsg|]}t|j��qSr)r�message)rrrrrr	�rmz<NodeVisitorTests.test_old_constant_nodes.<locals>.<listcomp>)�+visit_Num is deprecated; add visit_Constantr�r�z+visit_Str is deprecated; add visit_Constantz-visit_Bytes is deprecated; add visit_Constant�4visit_NameConstant is deprecated; add visit_Constantr�z0visit_Ellipsis is deprecated; add visit_Constant)
r+�NodeVisitorrqr�warnings�catch_warnings�filterwarnings�DeprecationWarning�visitr:)r0r�r��visitor�wlogrr�r�test_old_constant_nodes�s
�
z(NodeVisitorTests.test_old_constant_nodesN)rr.rOr�rrrrr�sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ModuleStateTestscCs<d}d}d}t|||tjd�}t|||�}|�|tj�dS)Nzx + 1rprZ)�flags)rir+rjr��types�CodeType)r0r��filenamerCrnrrr�check_ast_module�sz!ModuleStateTests.check_ast_modulecCspt�tjdd��tjd=ddl}tjd=ddl}|��Wd�n1s'wY~~t��|��dS)N�_astr)r�	swap_item�sys�modulesr�r�rU)r0�ast1r�rrr�test_reload_module�s
�
z#ModuleStateTests.test_reload_modulec	s�t���fdd�}t�tjdd��Atjd=t�td|��|��|�dtj�ddl	}|�
|��Wd�n1s=wYWd�dSWd�dS1sUwYdS)Ncs�tj|<�Sr�)r�r�)r1r�r���lazy_modrr�	my_import�s
z4ModuleStateTests.test_sys_modules.<locals>.my_importr��
__import__r)�objectrr�r�r�r�builtinsr��assertNotInr�r�)r0r�r�rr�r�test_sys_modules�s��"�z!ModuleStateTests.test_sys_modulescCs"td�}t�|�}|�|d�dS)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:)r0r��resrrr�test_subinterpreter�s
z$ModuleStateTests.test_subinterpreterN)rr.rOr�r�rrrrrrr��s

r�cCs�tdkrdStjdd�dgkrEtdftdftdffD]#\}}t|d�|D]}t�|d|�}td	t	|�f�q'td
�qtd�t
�t��dS)N�__main__r�z-grXrYrZz_results = [r^z%r,�]zmain())
rr��argvrarcre�printr+rqr�
SystemExit�unittest�main)�
statementsr`�	statementrtrrrr
	s�
r
r�)r��r�rr�r��r�r
NN)r��r�rr��)r�rzmodule docstringNr�)r�rr�rerr�)r�)r�rr�re)r�rr��)r��r�rr�r)r�rzfunction docstringN)r�rr�r��r��r�rsr�r�rRNN)r�)r�rr�r�)r�rr�r�)r��r�r�r�rrN)r�)r�r�r�r�r)r��r�r�r�rdr�NN)r�)r�r�r�r)r�rr��)r��r�r�r�r�r�NN)r�)r�r�r�r)r�rr��G)r)r��r�rr�rr'NN)r��r�r�r�r{r�NN)r��r�r�r�r[rYNN)r�)r��r�rrNN)r��r��#r��'r�NN)r�)r��)r�rBrNN)r�)r��+r��-rBN)r�)r��1r��7r�NN)r��r�rdr�r�r�N)r��r�r�r��NNr)r��r���r�r�)r��r�� )r��r��:r�r)r�r.zdoc for f()Nr�)r�rr�r��C)r�)r�r�r�r�)r�rr�r-)r��r�rr�r-)r�r1zdocstring for class CN)r�rr�r+)�Return�r�r�r�r�)r��r�r{r�r�r�Nr��r�rr�r�)r��r�r�r�r�r()�Delr��r��r�rr�r�r(�r�)r�r6r�N�r�rr�r�r�r�rr�r�)r�r9rRr:)r��r�rDr�r�r'r:r:)r�rr�r+)r�rr�r�r��r�r�r�rDrRr:)r��r�r�r�r�r'r:)r�rr�r+)r��r�rr�rsr8�r�)r��r�r�r�rsr�Nr�)r�rr�r{)r�r6r(r:)r�rr(r+)r�)r�rdr�r{r�)r�rr(r+r�)r�r@r(r+)r�)r�r�r�r)r�rr�rs)r�r@rRr+)r�)rDrDrDrs)r�rr�rs)r�)r�r�r�rsr'r+)r�)r�rDr�rs)r�rrsrs)r�rrsrs)r�)rsrDrsrsr�)r�rr�r�)r)r�rCrKr+)r��r�rr�rdr�r:)r�)r�rer�r�)r�rr��)r)r��r�rer�r�r�r+)r��r�rr�r��qr:)r�)r�rr�rEr?rE)r�rsr�rE)r�)r�rsr�r{r)r+)r�)r�r�r�r)r/Nr�r�)r��r�r�r�r�r)r+)r��r�rr�r�)r��r�r�r�r�r(r+Nr�)r�rr�r)r��r�r�r�rr�Nr�r�)r��r�r�r�r�r(Nr�rJr()r�r9�r�r9r�N)r�r
)�Break�r�rdr�r�)r�rr�r�)�Continue)r�rdr�r�)r�r�r�r�)r�r6rRr:)r�rr'r:)r�r&r�r+)r�rr�r()r�r�r�r)r�rCrRr:)r�rKr'r:)r�rFr�r+)r�r'r�)r�rrdr�r�)rDr�rsr�)r�)r�r�r�rs�Aar+)r�)r�r�r�r�Bbr+r�)r�r�rrs)r�)r�r�r�rsrRr:)r�)rr�rrsrSr:)r�)rrrr��Ccr+)r�rr��"r��r�r?rRr+)r�rCr'r+)r�r&rr:)r�rMrKr+)r�rr�r:)r�)r��r�rr�r+)r�)r�r-r��!r�r+)r�rdr�r�)r�r&r(r:)r�rFrr:)r�rGrKr+r�)r�r?r�r+)r�rKr�r:)r��r�r�r�rerKr+)r��r�r�r�rr�r+rL)r�rr�r:)r�rrKr+�AsyncFunctionDef)r�rr�r)r��rDr�rDr�)r�r\zasync functionN)r�r�r�r�Await)r�r�r�r)r�rI�	somethingr+)r�rr�r��AsyncFor)rDr�r�r�)r�)rDrdrDr�rr:)r�)rDr�rDr�rlr+)r��rDr�rDr()r�r`r�N)r��r�r�r�r�)r�rarDN)r�rrDr�	AsyncWith)rDr�rDr)r)r�)rDr�rDrerRr+)r�)rDr�rDrr'r:)r��rDr(rDr)r�rcr�N)r�rDrDN)r�r�r�r�)r�rrDN)r�rYr�Nr�r)r�r�r�r�)r�rDr�r�)r�r@r�N)r�rDr�Nr�)r�)rDrDrDr�rlr+)r�)rDr�rDr{r'r:)r�r`r�r+r�)r�rr�re)r�)r�rr�re)r��r�r�r�rs�deco1r+)rDr�rDr�)r�)rDr�rDrs�deco2r+)r�r�r�r)r�)r�r�r�rs�deco3r+)r�rar�N)r�rr�r�)r�)r�r{r�r�)rDrrDre)r�)rDrrDre)r�r�r�r�)r��r�r�r�r��decor+)r�r�r�r�)r�rrRr+)r�rYrRr:)r�rZr'r+)rrd)r)r�r�r�r�rVr'r+r�r+)r�rJ)�	NamedExpr)r�r�r�r�r>)r�rr�N)r�rr�r*)�r�rYr�NN)r�r4rYNN)r�rGrNN)r�)r�r�r�r*rk)r�rGrYNN)r��r�rr�r�rNN)r�)r�rEr�r)r�rr�r )r�)r�r*r�r-r�NN)r�r�r�rr�N)r�rr'NN)r�)r�r�r�r(r�NN)rm�r�rMrDN)r�rlr�N)r�rr�NN)r�)r�r)r�rEr�Nrn)r�)r�rr�r-)r�rr�r,)r�)r�r*r�r,)r�rr�rB)r�)r�rr�rr�NN)r�)r��&r�rB)r�rr�r�)r�)r�rWr�rXr�NN)r�)r��$r�r�r�)r�r<)r�r<rNrB�r�r=rDN)r�rr�r�)r��r�r9rRr+)r�rr'r+)r�)r�r5rrrB�r�r6r'r+)r�)r�r5)r�)r�r6r(r+r�)r�rr�rd)r�rNN�r�r=r�N�r�r6rDN�r�rr�rD)r�rhNN)r�rr�rs)r�)rDrsrDr�r�N)r�)r�rr�rdrDN)r�rYr�r+)r�rZrYr+rd)r�r=rRr+rs)r�r&rRr:)r�rFr'r:)r�rGr�r+)r�rr�r�rP)r�rr'r:)r�)r�r(r�rr�r+r�rN)�Lt�r�rr�N)r�r9rr+)rtru)r)r�rr�r�)r�r&rYr+r+)r�)r�rsr�rr�rx)r�)r�rer�r�N)r�r4rr+)r�rDr�r)r�r�r�r)r�r6rN)r�rKr�N)r�r�r�r{)r�rrRr:)r�rFr'r+)r�)r�rvrN)r�)r�rJr/N)r��rr<rrr'r+)r�)rrArr)r)r�rDr�r�)r�r=r'r+)r�r6r�r+Nr+)r�)r�r9r(r+))r�r?r�N)r�r@rDN)r�rCr�N)rNrq)r�r6r�N)rr;)rr5ryr�r+rYr+)rr3)r)r�r�r�rd)r�rrRr+r'r+)r)r�r�r�r{)r�rYr�N)r�rrDNNr+)r+r�rcr r�r�r	r�rS�textwraprrMrrrarcre�TestCaser*r%r�rOrtr�r$r�r
rbrdrfrrrr�<module>s�
�KuZ2Q
�
�,�,�.�0�,�,�L	�
���,
���"�"�"�
����$�&����&��
�� �!�
"�
#�$�%�&&�&'�&(�<)�4*�2+�&,�0-�D.�>/�:0�,1�,2�F3�H4�H5�66�N7�.8�
9�.:�2;�8<�8=�0>�6?�8@�8A�8B�<C�F�����&����	�"
�"�@�B
�B�@�B�B�@�B�B�&�"�2�2�������� �!�"�#�
%

Youez - 2016 - github.com/yon3zu
LinuXploit