Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_ast.cpython-39.opt-1.pyc

a

��g^��O@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�Zddggfddggfdddddggdggdgfd ggddfggfddd!ddggdggdgfd"ggddfggfddd#ddgd$gdggdgfd%ggddfggfddd&ddgd$gdggdd'gfd(ggddfggfddd)ddggd*ggdgfd+ggddfggfddd,ddggdggd-gfd.ggddfggfddd/ddggd0�d1d2gd3gd4d5d6d7d8gd9fd:d;ggfgfd<ggddfggfdd=d>d?ggd@ggfggfdd=dAd?ggdBggfggfdd=d,d?dCggd.ggfggfddd&ddggdggdgfdDggddfggfddEdFdGgfggfddHdFdIgdJdfggfddHdKdLdMdNdOgdPfgdQdfggfddHdRdLdFdSdTgdPfgdUdfggfddHdRd7dFdSdTgdPfgdUdfggfddVggfddWdXdYdZd[ggdfggfdd\d>d]d@ggfggfdd^dRd_d`ggfggfdd^dadbdcgd^dddedfggfgfggfdd^dgdbdcgd^dhdedfgdigfgfggfddjdkdlgdmgdfggfddjdndldogdpgdfggfddqdndrdsdtduggfdfggfddvdadcgdwdddxddfgfgggfggfddvdadcgggdfgfggfddyggfddzd{d|gfggfdd}dkd~dgdfggfdd�d�d�gfggfdd�ggfdd�ggfddWd&dYdZd�ggdfggfddWd�dYdZd�ggdfggfddWd)dLd�d�d�gdPfd�d+ggdfggfddWd�dLd�d�d�gdPfd�d�ggdfggfddWd�d7d�d�d�gdPfd�d�ggdfggfdd�d�d�d�dLd�d�d�gd9fd�dLd�d�d�gdPfd�gdfgffggfdd�d�d�d�d�d�d�d�d�gdfd�d�d�d�gdfgffggfdd�d�d�d�d�d�d�dLd�d�d�gdPfd�gdfgffggfdd�d�d�d�d�d�d�d�d�gdfgffggfdd�d&d�d&d�d�dLd�d�d�gdPfd�gdfgffggfdd�d�ddggdggdgfd�d�d�d�d�drd�d�ggfffggddfggfdd�d�ddggdggdgfd�d�d�d�d�gd�gdfggddfggfdd�d�ddggdggdgfd�d�d�gd�gdfggddfggfdd�d#d:d#dd�gd:d�dJgd�gfd�gffggfdd�d>d�d>d�d�d�d�d�d�gfd9fd�gffggfdd�d�ddggdggdgfd�d�d�d�d�d�d�d�gd�fgffggddfggfddd�ddggdggdgfd�gd�drd�d�ggfdrd�d�d�ggfgddfggfdd�d�ddggdggdgfd�gd�drd�d�ggfdrd�d�d�ggfgddfggfdd=d�d?ggd�gd�drd�d�ggfdrd�d�d�ggfgfggfddd�ddggdggdgfd�gdrd�d�d�d�d�d�d�d�gdfgfggfgddfggfddd�ddggdggdgfd�gd�gddfggfdd�ggfddd)ddd$ggdggdgfd+ggddfggfddd�ddd$ggd�dggdgfd�ggddfggfddd!ddd$gd�gdd�d�gddgdgfd�ggddfggfddd�ddd$gd�gdd�d�gddgd�gfd�ggddfggfddd�ddd$ggdggdd�gfd�ggddfggfddd!ddd$gd�d�gdggdgd��fd�ggddfggfdddAddd$gd�gdd�gd�gdd�d�gfd�ggddfggfddd�ddd$gd�gdd�gdgdd�d�gfd�ggddfggfddd�ddd$gd�gdd�gd�gd�d�d�gfd�ggddfggfddd�ddd$gd�gdd�gdg�dd�d�gf�dggddfggfgCZ�d�dgfgZ�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�d9ggffg#Ze�dS(:�N)�dedent)�supportcCs�|dust|tttf�r|St|t�r4dd�|D�S|jjg}t|d�r�t|d�r�|�|j	|j
f�t|d�r�t|d�r�|d|j|jf7<|j
dur�t|�S|j
D]}|�tt||���q�t|�S)NcSsg|]}t|��qS�)�to_tuple)�.0�err�)/usr/local/lib/python3.9/test/test_ast.py�
<listcomp>�zto_tuple.<locals>.<listcomp>�lineno�
col_offset�
end_lineno�end_col_offset���)�
isinstance�str�int�complex�list�	__class__�__name__�hasattr�appendrrr
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)Z10z'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�Zejd3d4��Zd5d6�Zd7d8�Z d9d:�Z!d;d<�Z"d=d>�Z#d?S)@�	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|jdurdSt|tjtjtjf�rT|j|jf}|�	||�|j|jf}|jD]h}t
||�}t|t�r�|}|r�|dkr�|dj|djf}|D]}|�||�q�qZ|durZ|�||�qZdS)N�decorator_listr)
rr+r,r�expr�stmtZ
excepthandlerrrZassertGreaterEqualrr�_assertTrueorder)r0�ast_nodeZ
parent_posZnode_posr1�valueZ	first_pos�childrrrr7s 


zAST_Tests._assertTrueordercCs�t��}|�|jd�d|_|�|jd�|�|jdd�|�t��|jWd�n1sb0Y|�t	��t�d�Wd�n1s�0YdS)Nr�*�foobar�)
r+r,�assertEqualrr<�__dict__�assertRaises�AttributeError�vararg�	TypeError�r0�xrrr�test_AST_objectss$zAST_Tests.test_AST_objectscCsLGdd�d�}t��}|�|_||j_t�|j�}~t��|�|��dS)Nc@seZdZdS)z0AST_Tests.test_AST_garbage_collection.<locals>.XN�rr.�__qualname__rrrr�X$srI)	r+r,rE�a�weakref�refr�
gc_collect�assertIsNone)r0rIrJrLrrr�test_AST_garbage_collection#sz%AST_Tests.test_AST_garbage_collectionc
Cs�ttdfttdfttdffD]�\}}}t||�D]�\}}|jd|d��<t|d|t	j
�}|�t|�|�|�
|d�Wd�n1s�0Y|jd||d	��t|d|�Wd�q01s�0Yq0qdS)
N�exec�single�evalZparsing)�action�input�?)rrZ	compiling)rSrT�kind)�
exec_tests�exec_results�single_tests�single_results�
eval_tests�eval_results�zip�subTest�compiler+�
PyCF_ONLY_ASTr>rr7)r0rT�outputrV�i�o�ast_treerrr�
test_snippets.s�*zAST_Tests.test_snippetscCs0ttt}|D]}t�|�}t|dd�qdS)N�<string>rP)rWrYr[r+�parser_)r0Zsnippets_to_validateZsnippet�treerrr�test_ast_validation:s
zAST_Tests.test_ast_validationcCs<t�d�jdjj}|�|j�|�|j�|�|j�dS)Nzx[::]r)	r+rg�bodyr9�slicerN�upper�lower�step)r0Zslcrrr�
test_sliceAszAST_Tests.test_slicecCs t�d�jd}|�|j�dS)Nzfrom . import yr)r+rgrjrN�module)r0�imrrr�test_from_importGszAST_Tests.test_from_importcCs>t�d�}|�|jdtj�d��|jd_t|dd�dS)Nzfrom __future__ import divisionrz __future__ �<test>rP)r+rg�assertIsInstancerj�
ImportFrom�striprpr_)r0�modrrr�!test_non_interned_future_from_astKs
z+AST_Tests.test_non_interned_future_from_astcCs||�ttjtj��|�ttjtj��|�ttjtj��|�ttjtj��|�ttjtj��|�ttj	tj��dS�N)
�
assertTrue�
issubclassr+�Forr6�Namer5r,�
comprehensionZGt�r0rrr�test_base_classesQszAST_Tests.test_base_classescCsRtj��D]B\}}|�||�r
|dkr(q
|�}t|tj�r
|�t|j�t	�q
dS)NZIndex)
r+r?�itemsr3rr,r>r-rr)r0r1�itemrErrr�test_field_attr_existenceYsz#AST_Tests.test_field_attr_existencecCs�t��}|�|jd�|�t��|jWd�n1s<0Y|�|j�tjt	dd��}|�|jd�|�|jd�dS)N)�posonlyargs�argsrB�
kwonlyargs�kw_defaults�kwarg�defaults��r=�)
r+�	argumentsr>rr@rAr�rNrB�rangerDrrr�test_argumentsds$zAST_Tests.test_argumentscCs t��}d|_|�|jd�dS)Ni�)r+�Numrr>rDrrr�test_field_attr_writableqsz"AST_Tests.test_field_attr_writablecCs�t��}|�|jd�|�t��|jWd�n1s<0Y|�t��|jWd�n1sl0Yt�d�}|�|jd�|�|jd�|�t��|jWd�n1s�0Y|�t��|j	Wd�n1s�0Ytjdd�}|�|jd�tjddd�}|�|jd�|�|jd�|�|jd�|�|jd�|�t
tjddd�|jt
tjddddd�|�tjddd�jd�|�tjddd�jd�|�
t
d	��tjddd
�Wd�n1�s�0Y|�
t
d��tjddd�Wd�n1�s&0Y|�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)r9rVr;r=�rrr�Zbar)�fooz(Num got multiple values for argument 'n'��nz1Constant got multiple values for argument 'value'�r9�@�@�42�42TF.)r+r�r>rr@rAr9r�rr<rC�Constantr��assertRaisesRegex�Str�s�Bytes�assertIs�NameConstantrDrrr�test_classattrswsZ$$
$$..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)Nr;r�r�r�r�TF)	r>r-r+r�r�r�r�r��Ellipsisrrrr�
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)Nr;g������@y������@r�r�TF.c@seZdZdS)z$AST_Tests.test_isinstance.<locals>.SNrGrrrr�S�r
r�)rzrr+r�r�r�r�r�r��assertFalser)r0r�rrr�test_isinstance�sPzAST_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__�z)r0r��kwargs�rrrr��sz-AST_Tests.test_subclasses.<locals>.N.__init__)rr.rHr��
__classcell__rrr�r�N�sr�c@seZdZdS)z%AST_Tests.test_subclasses.<locals>.N2NrGrrrr�N2�sr�r;r�r�)	r+r�r>r�r�r-rzrr�)r0r�r�r�rrr�test_subclasses�s
zAST_Tests.test_subclassescCs*t�d�g}t�|g�}|�|j|�dS)Nr;)r+r��Moduler>rj)r0rjrErrr�test_modules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�r=rr��)r�r�r�rr;)�	foobarbaz)
r+�BinOpr>rr�r��Addr�r�r�rr@rC)r0rEZn1Zn3Zaddoprrr�test_nodeclassess:

zAST_Tests.test_nodeclassescCst��}|�|jd�dS)Nr)r+ZSubr>rrDrrr�test_no_fields2szAST_Tests.test_no_fieldsc		Cs�ddl}|g}zddl}|�|�Wnty6Yn0gd�}|D]H}|D]>}dd�tD�D]*}|�|�||��}|�t|�t|��q^qLqDdS)Nr)rr�r=css|]}t|ddd�VqdS)rUrPiN)r_)rrbrrr�	<genexpr>Br
z*AST_Tests.test_pickling.<locals>.<genexpr>)	�pickle�cPickler�ImportErrorrW�loads�dumpsr>r)	r0r�Zmodsr�Z	protocolsrw�protocolr+�ast2rrr�
test_pickling7szAST_Tests.test_picklingcCs�tddd�}t�tjtjfi|��fi|��gg�}|�t��}t|dd�Wd�n1s`0Y|�dt	|j
��dS)Nr=r��rrrsrPzbut got <ast.expr)�dictr+r��Exprr5r@rCr_�assertInr�	exception)r0�pos�m�cmrrr�test_invalid_sumFs
(*zAST_Tests.test_invalid_sumc	Csvt�t�t�dt����gg�}t�|�|�t��}t|dd�Wd�n1sV0Y|�	dt
|j��dS)Nr;rsrPzidentifier must be of type str)r+r�r�r}�Load�fix_missing_locationsr@rCr_r�rr�)r0r�r�rrr�test_invalid_identifierMs
 
*z!AST_Tests.test_invalid_identifierc	Csxtddtftddtf�fD]X}tjt�|�d�}t�|�|�td��t|dd�Wd�q1sh0YqdS)Nr�r=�rjzinvalid type in Constant: typersrR)	r�	frozensetr+�
Expressionr�r�r�rCr_)r0Zinvalid_constantrrrr�test_invalid_constantTs
�zAST_Tests.test_invalid_constantcCsjt�d�}d|jdjdj_|�t��}t|dd�Wd�n1sJ0Y|�dt|j	��dS)Nzdef f():
 yield from g()rrsrPzfield 'value' is required)
r+rgrjr9r@�
ValueErrorr_r�rr�)r0Zempty_yield_fromr�rrr�test_empty_yield_from]s

*zAST_Tests.test_empty_yield_fromcCsRddl}dd�}t�|d|�� |�ttjd�Wd�n1sD0YdS)NrcWsdSryr�r�rrr�
bad_normalizejsz0AST_Tests.test_issue31592.<locals>.bad_normalize�	normalizeuϕ)�unicodedatar�	swap_attrr@rCr+rg)r0r�r�rrr�test_issue31592eszAST_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+7r�r�r�z
4+5-\
 6-7r�r�r=)
r+rgrjr9r�r>rrrr
)r0rhZparent_binopZchild_binopZgrandchild_binoprrr� test_issue18374_binop_col_offsetos4

z*AST_Tests.test_issue18374_binop_col_offsetcCs.t�d�}|jdjdj}|�|jd�dS)Nr#rr�)r+rgrjr4r9r>r)r0rhZattr_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	�r
z5AST_Tests.test_ast_asdl_signature.<locals>.<listcomp>zexpr = r�
)r>r+�withitemr�r�r}Zcmpopr5�__subclasses__ZassertCountEqual�split)r0Zexpressionsrrr�test_ast_asdl_signature�sz!AST_Tests.test_ast_asdl_signaturecCsJtjddd�|�t��tjddd�Wd�n1s<0YdS)Nzf"{x=}")r�r�)Zfeature_version)r�r�)r+rgr@�SyntaxErrorrrrr�test_issue40614_feature_version�sz)AST_Tests.test_issue40614_feature_versionc	CsndD]d}t�t�|t����}t�|�|�td|�d���t|dd�Wd�q1s^0YqdS)N)�True�FalserzName node can't be used with 'z
' constantrsrR)r+r�r}r�r�r�r�r_)r0Zconstantr5rrr�test_constant_as_name�s

zAST_Tests.test_constant_as_nameN)$rr.rHr3r7rFrOrerirorrrxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�cpython_onlyr�r�r�r�r�r�rrrrr*�s@
</,	
		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�ZdS)2�ASTHelpers_TestNcCs6t�d�}tdddtj�}|�t�|�t�|��dS)Nz
foo(1 + 1)z	<unknown>rP)r+rgr_r`r>�dump)r0rJ�brrr�
test_parse�s
zASTHelpers_Test.test_parsecCsfzddWnTty`|�t��}t�d�Wd�n1sD0Y|�|jj�Yn0dS)Nr�rz'\U')�	Exceptionr@r�r+�literal_evalZassertIsNotNoner��__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+rgr>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�	)r�rz�Module(
	[
		Expr(
			Call(
				Name('spam', Load()),
				[
					Name('eggs', Load()),
					Constant('and cheese')],
				[]))],
	[])T)r�ra�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�rrr�test_dump_indent�s
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()Tr�zRaise(lineno=3, col_offset=4)r)�id�ctx)�excrr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}r�r�rrr�test_dump_incompletes6��������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 + 1rR��moder=Tr�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))r�)rrr
r)rr)r+rg�
copy_locationr�rjr�r>r��CallrNr
rrr)r0�src�newrrr�test_copy_location(s�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�ZeggsTr�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=[]))
r+rgrjrr�r
r}r�r�r>r��maxDiffr��r0rrrr�test_fix_missing_locations8s
��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)
Nr	rRr
r�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))�testr�)�funcr��keywordsrr=)r+rgr>Zincrement_linenor�rjr
r}r�rrNr
rrrr�test_increment_linenoLs���z%ASTHelpers_Test.test_increment_linenocCsHtjddd�}tt�|j��}|�|�d�jd�|�|ggd��dS)N�foo()rRr
rr�)rr�)r+rgr�Ziter_fieldsrjr>�popr)r0r2�drrr�test_iter_fieldsdsz 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')rRr
r�r��r;z1keyword(arg='eggs', value=Constant(value='leek')))r+rgr>�lenrZiter_child_nodesrj�nextrr9r�)r0r2�iteratorrrr�test_iter_child_nodesjs�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+rgr>�
get_docstringrjr�rrr�test_get_docstringus
�
�
�
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")rNr+r!rgrjr�rrr�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�r=r�r��	��
)r+rgr>rjrrr�rrr�:test_multi_line_docstring_col_offset_and_lineno_issue16806�s�  zJASTHelpers_Test.test_multi_line_docstring_col_offset_and_lineno_issue16806cCs:t�d�}|jdjd}|�|jd�|�|jd�dS)Nz if a:
    pass
elif b:
    pass
rr��r+rgrj�orelser>rr�r0r2Z	elif_stmtrrr�test_elif_stmt_start_position�s
z-ASTHelpers_Test.test_elif_stmt_start_positioncCs:t�d�}|jdjd}|�|jd�|�|jd�dS)Nz/if a:
    pass
elif b:
    pass
else:
    pass
rr�r)r+rrr�'test_elif_stmt_start_position_with_else�s
z7ASTHelpers_Test.test_elif_stmt_start_position_with_elsecCs<t�d�}|jdjjd}|�|jd�|�|jd�dS)Nr&rr�r%)r+rgrjr9r�r>r
r)r0r2Zstarred_exprrrr�*test_starred_expr_end_position_within_call�s
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�r=r�z{"foo": 42}r�r;z(True, False, None))TFNz	{1, 2, 3}>r�r=r�zb"hi"shizset()r�6�z+6z-6i����z3.25g
@z+3.25z-3.25g
�z-0.0z++6z+Truez2+3)r>r+r��setr@r��reprrrrr�test_literal_eval�s"z!ASTHelpers_Test.test_literal_evalc	Cs�t�d��rt�d�|�t��}t�d�Wd�n1s@0Y|�dt|j��|�dt|j��Wd�n1s�0YdS)Ni�A�3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333A�33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333zExceeds the limit z Consider hexadecimal )	rZadjust_int_max_str_digitsr+r�r@r�r�rr�)r0Zerr_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)NZ6jy@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�r@r�rrrr�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�r=r�)�keys�values)r+�Dictr�r@r�r�)r0Z	malformedrrr�&test_literal_eval_malformed_dict_nodes�s&&z6ASTHelpers_Test.test_literal_eval_malformed_dict_nodescCsxtjdtjdd�gdddd�g}t�|g�}|�t��}t|dd�Wd�n1sX0Y|�dt|j	��dS)N�time�sleep�r1�rp�names�levelrrrrPzinvalid integer value: None)
r+ru�aliasr�r@r�r_r�rr�)r0rjrwr�rrr�test_bad_integer�s�*z ASTHelpers_Test.test_bad_integercCsVtjdtjdd�gdddd�g}t�|g�}t|dd�}i}t||�|�d|�dS)Nr;r<r=rr>rrP)r+rurAr�r_rPr�)r0rjrw�code�nsrrr�test_level_as_nones�
z"ASTHelpers_Test.test_level_as_nonec	Cs�tjt��ddd�}||_|�t��Jt���"tt�	|�dd�Wd�n1sV0YWd�n1st0YdS�Nr)r�rrrsrR�
r+�UnaryOp�Not�operandr@�RecursionErrorrZinfinite_recursionr_r�r�rrr�test_recursion_directs

z%ASTHelpers_Test.test_recursion_directc	Cs�tjt��ddd�}tjt��ddd�}||_||_|�t��Jt���"tt�	|�dd�Wd�n1sp0YWd�n1s�0YdSrFrG)r0rrrrr�test_recursion_indirects
z'ASTHelpers_Test.test_recursion_indirect)rr.rHrr�r�r�rrrrrrr r"r$r(r,r-r.r4r5r6r:rBrErLrMrrrrr��s2=r�c@s�eZdZd`ed�dd�Zdaed�dd�Zdbdd	�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_�Z1dS)c�ASTValidatorTestsNrP�rcCsxd|_|_t�|�|dur,t|d|�nH|�|��}t|d|�Wd�n1sX0Y|�|t|j��dS)Nrrs)	rrr+r�r_r@r�rr�)r0rw�msgrrr�rrrrw!s
*zASTValidatorTests.modcCs(t�t�|�gg�}|j|||d�dS)NrO)r+r�r�rw)r0r2rPrrwrrrr5+szASTValidatorTests.exprcCst�|gg�}|�||�dSry)r+r�rw)r0r6rPrwrrrr6/szASTValidatorTests.stmtc	CsTt�t�t�dt����g�}|�|dd�t�t�dt����}|�|dd�dS)NrE�must have Load contextrQrR)r+�Interactiver�r}�Storerwr�)r0r�rrrr�3szASTValidatorTests.test_modulec	sd�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|durg}|durg}|dur$g}|dur0g}|dur<g}t�|||||||�}�|�Sry)r+r�)r�r�rBr�r�r�r���facrrr�:s�z5ASTValidatorTests._check_arguments.<locals>.argumentsrEr�rQ)r�)r�r�)r�z"more positional defaults than argsr�)r�z3length of kwonlyargs is not the same as kw_defaults)r�r�rJr��y)r�r�)NNNNNNN)r+�argr}rSr�r�)r0rU�checkr�r�rrTr�_check_arguments9s4�������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)NrEzempty body on FunctionDefrQcSst�d|t��ggd�S�NrE)r+�FunctionDef�Passr�rrrrUesz+ASTValidatorTests.test_funcdef.<locals>.fac)r+r�r[r6r\r}rSrY)r0rJrrUrrr�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|durg}|durg}|dur*t��g}|dur6g}t�d||||�S)NZmyclass)r+r\�ClassDef)�basesrrjr4rrr�clsjs

�z,ASTValidatorTests.test_classdef.<locals>.clsrE)r_rQ)rr�zempty body on ClassDef�None disallowed)r4)NNNN)r6r+r}rS�keyword)r0r`rrr�
test_classdefis
�"��zASTValidatorTests.test_classdefc	CsJ|�t�g�d�|�t�dg�d�|�t�t�dt���g�d�dS)Nzempty targets on DeleterarEzmust have Del context)r6r+�Deleter}r�rrrr�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 AssignrarE�must have Store contextrVrQ)r6r+�Assignr�r}r�rSrrrr�test_assign�s"���zASTValidatorTests.test_assignc	Cspt�t�dt���t��t�dt����}|�|d�t�t�dt���t��t�dt����}|�|d�dS)NrErVrfrQ)r+�	AugAssignr}r�r�r6rS)r0Zaugrrr�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)NrErVzempty body on ForrfrQ)r+r}rSr�r\r6r|r�)r0rErV�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 WhilerErQ)r6r+�Whiler�r}rSr\r�rrrr�
test_while�s"���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 IfrErQ)r6r+�Ifr�r}rSr\r�)r0rbrrr�test_if�s (�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 WithrErQrf)	r+r\r6�Withr�r�r}rSr�)r0rkrbrrr�	test_with�szASTValidatorTests.test_withcCspt�dt�d��}|�|d�t�t�dt���d�}|�|d�t�t�d�t�dt����}|�|d�dS)Nr�z!Raise with cause but no exceptionrErQr�)r+rr�r6r}rS)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 TryrErQz-Try has neither except handlers nor finalbodyz%Try has orelse but no except handlerszempty body on ExceptHandlerrV)r+r\�Tryr6r�r}rS�
ExceptHandler)r0rkrrrrr�test_try�s$&((zASTValidatorTests.test_tryc	CsT|�t�t�dt���d�d�t�t�dt���t�dt����}|�|d�dS)NrErQrV)r6r+�Assertr}rSr�)r0Zassrtrrr�test_assert�s��zASTValidatorTests.test_assertcCs|�t�g�d�dS)Nzempty names on Import)r6r+�Importrrrr�test_import�szASTValidatorTests.test_importcCs>t�dt�dd�gd�}|�|d�|�t�dgd�d�dS)NrEi���zNegative ImportFrom levelrzempty names on ImportFrom)r+rurAr6)r0�imprrr�test_importfrom�sz!ASTValidatorTests.test_importfromcCs|�t�g�d�dS)Nzempty names on Global)r6r+�Globalrrrr�test_global�szASTValidatorTests.test_globalcCs|�t�g�d�dS)Nzempty names on Nonlocal)r6r+ZNonlocalrrrr�
test_nonlocal�szASTValidatorTests.test_nonlocalcCs&t�t�dt����}|�|d�dS�NrErQ)r+r�r}rSr6r�rrr�	test_expr�szASTValidatorTests.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�rarErQ)r+�BoolOp�Andr5r�r}rS)r0r�rrr�test_boolop�s&zASTValidatorTests.test_boolopcCs,t�t��t�dt����}|�|d�dSr�)r+rHrIr}rSr5)r0�urrr�test_unaryop�szASTValidatorTests.test_unaryopc
CsPt�ggdggdg�}|�t�|t�dt����d�dd�}|�||j�dS)NrErQcSst�|t�dt����SrZ)r+�Lambdar}r�r�rrrrUsz*ASTValidatorTests.test_lambda.<locals>.fac)r+r�r5r�r}rSrY)r0rJrUrrr�test_lambdas�zASTValidatorTests.test_lambdacCsXt�dt���}t�dt���}|||f|||f|||ffD]}|�tj|�d�q<dS�NrErVrQ)r+r}r�rSr5ZIfExp)r0�lr�r�rrr�
test_ifexp	s zASTValidatorTests.test_ifexpcCsRt�gt�dt���g�}|�|d�t�t�dt���gdg�}|�|d�dS)NrEzsame number of keys as valuesra)r+r9r}r�r5)r0rrrr�	test_dictszASTValidatorTests.test_dictcCs<|�t�dg�d�t�t�dt���g�}|�|d�dS�NrarErQ)r5r+�Setr}rS�r0r�rrr�test_setszASTValidatorTests.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 generatorsrErrfrQrVra)r5r+r~r}r�rS)r0rU�grErVrrr�_check_comprehensions��z&ASTValidatorTests._check_comprehensioncsbt�t�dt���t�dt���gd�}|��t�dt���|g�d��fdd�}|�|�dS)NrErrQcs�t�dt���|�SrZ)r+r}rS)ZgensrTrr�wrap.sz,ASTValidatorTests._simple_comp.<locals>.wrap)r+r~r}rSr�r5r�)r0rUr�r�rrTr�_simple_comp)s��zASTValidatorTests._simple_compcCs|�tj�dSry)r�r+�ListComprrrr�
test_listcomp2szASTValidatorTests.test_listcompcCs|�tj�dSry)r�r+�SetComprrrr�test_setcomp5szASTValidatorTests.test_setcompcCs|�tj�dSry)r�r+�GeneratorExprrrr�test_generatorexp8sz#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)NrVrkrrErQcSs.t�dt���}t�dt���}t�|||�S)NrErV)r+r}r��DictComp)�comps�kr(rrr�factoryDsz0ASTValidatorTests.test_dictcomp.<locals>.factory)r+r~r}rSr�r�r5r�)r0r��cr�rrr�
test_dictcomp;s���zASTValidatorTests.test_dictcompc	Cs@|�t�t�dt����d�|�t�t�dt����d�dS)NrEzmust have Load)r5r+ZYieldr}rSZ	YieldFromrrrr�
test_yieldJszASTValidatorTests.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)NrEzno comparatorsr�r�z,different number of comparators and operandsZblah)r+r}r��CompareZInr5r�)r0r��comprrr�test_compareNs$
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)NrErV�wr�rQra)r+r}r�rbr
rSr5)r0rr�r�callZbad_keywordsrrr�	test_callYszASTValidatorTests.test_callcCszGdd�dt�}Gdd�dt�}Gdd�dt�}dD]}|�t�|��q4|�|�|�fD]}|jt�|�dtd	�qZdS)
Nc@seZdZdS)z*ASTValidatorTests.test_num.<locals>.subintNrGrrrr�subintfsr�c@seZdZdS)z,ASTValidatorTests.test_num.<locals>.subfloatNrGrrrr�subfloathsr�c@seZdZdS)z.ASTValidatorTests.test_num.<locals>.subcomplexNrGrrrr�
subcomplexjsr�)�0Zhellozinvalid typerO)r�floatrr5r+r�rC)r0r�r�r��objrrr�test_numeszASTValidatorTests.test_numcCs.t�t�dt���dt���}|�|d�dSr�)r+�	Attributer}rSr�r5)r0�attrrrr�test_attributeqsz 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�q�t�gt���}|�t�||t����t�|gt���}|�t�||t���d�dS)NrEr�rQrV)	r+�	Subscriptr}rSr�r�r5�Slice�Tuple)r0�subrEr�r��slrrr�test_subscriptus&�� 
�z ASTValidatorTests.test_subscriptc	CsNt�t�t�dt���t���gt���}t�|gt�d��}|�|d�dS)NrEr�rf)	r+�List�Starredr}r�rSrgr�r6)r0r��assignrrr�test_starred�s
 �zASTValidatorTests.test_starredcCs@|�|dgt���d�|�|t�dt���gt���d�dSr�)r5r+r�r}rS)r0rUrrr�	_sequence�s�zASTValidatorTests._sequencecCs|�tj�dSry)r�r+r�rrrr�	test_list�szASTValidatorTests.test_listcCs|�tj�dSry)r�r+r�rrrr�
test_tuple�szASTValidatorTests.test_tuplecCs|�t�d��dS)Nr�)r5r+r�rrrr�test_nameconstant�sz#ASTValidatorTests.test_nameconstantc
Cs�tj�tj�}dd�t�|�D�}|�ddg�|D]�}|�|��ltj�||�}t	|ddd��}|�
�}Wd�n1s~0Yt�||�}t||d�Wd�q41s�0Yq4dS)	NcSsg|]}|�d�r|�qS)z.py)�endswith)r�fnrrrr	�r
z;ASTValidatorTests.test_stdlib_validates.<locals>.<listcomp>ztest/test_grammar.pyztest/test_unpack_ex.pyrszutf-8)�encodingrP)
�os�path�dirnamer+�__file__�listdir�extendr^�join�open�readrgr_)r0Zstdlib�testsrpr��fp�sourcerwrrr�test_stdlib_validates�s&z'ASTValidatorTests.test_stdlib_validates)NrP)N)N)2rr.rHr�rwr5r6r�rYr]rcrerhrjrlrnrprrrtrwryr{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�r�r�rrrrrNs\

"	



	rNc@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�rfrPrE)r+rgrjr9r�rr_rP)r0r9rhr2�new_noderCrDrrr�compile_constant�s

zConstantTests.compile_constantcCsN|�t��}|�gd��Wd�n1s.0Y|�t|j�d�dS)Nr/z%got an invalid type in Constant: list)r@rCr�r>rr�)r0r�rrr�test_validation�s
,�zConstantTests.test_validationc	Cs^dddtdt�fD]F}|j|d��&|�|�}|�||�Wd�q1sN0YqdS)NFTr
)�const)r�r�r^r�r�)r0r�r9rrr�test_singletons�s
zConstantTests.test_singletonsc	Cs�d}tdh�}td�D]}|df}t|dh�}qddddd	td
�td�||f	}|D]F}|j|d��&|�|�}|�||�Wd�qR1s�0YqRdS)
N)r�r�r�r=�{g�^@y�^@�unicode�bytesrr�r�)r�r�rr^r�r>)r0Znested_tupleZnested_frozensetr@r8r9rrrr�test_values�s
�
zConstantTests.test_valuescCs�t�d�}|jdjd}tjdd�}t�||�||jdjd<|�t��}t|dd�Wd�n1sn0Y|�	t
|j�d�dS)N�x = 1rr�r��stringrPz6expression which can't be assigned to in Store context)r+rgrj�targetsr�rr@r�r_r>rr�)r0rh�target�
new_targetr�rrr�test_assign_to_constant�s
*�z%ConstantTests.test_assign_to_constantcCs t�d�}|�t�|�d�dS)Nz'docstring'
x = 1Z	docstring)r+rgr>r!)r0rhrrrr"�s
z ConstantTests.test_get_docstringcCs:t|dd�}g}t�|�D]}|jdkr|�|j�q|S)NrfrPZ
LOAD_CONST)r_�disZget_instructions�opnamerZargval)r0rh�co�constsZinstrrrr�get_load_const�s
zConstantTests.get_load_constcCs�gd�}d�dd�|D��}|d7}|�tdf�t�|�}|�|�|�|�t|j|�D](\}}tj	|d�}t�
||j�||_qZ|�|�|�|�dS)N)	NTF�|g@y@r�r�r/r�cSsg|]}d�|��qS)zx={!r})�format)rr�rrrr	�r
z1ConstantTests.test_load_const.<locals>.<listcomp>z
x = ...r�)r�r�r�r+rgr>r�r]rjr�rr9)r0r�rCrhr�r�r�rrr�test_load_const�s	
��zConstantTests.test_load_constcCslt�d�}|jdj}tjdd�}t�||j�||_tjdd�}t�||j�||_|�t�	|�d�dS)Nz1 + 2r�
r�y4@y$@4@)
r+rgrjr9r�rr�r�r>r�)r0rh�binopZnew_leftZ	new_rightrrrr4
s
zConstantTests.test_literal_evalcCs�tjddd�j}|�|jd�|�|jd�tjddd�j}|�|jd�|�|jd�tjddd�j}|�|jd�|�|jd�tjddd�j}|�|jd	�|�|jd�dS)
Nz"x"rRr
rEzu"x"r�zr"x"zb"x"�x)r+rgrjr>r9rV)r0r�rrr�test_string_kindszConstantTests.test_string_kindN)rr.rHr�r�r�r�r�r�r"r�rr�r�r4r�rrrrr��s

r�c@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|�dSry)r>r
r)r0r8r
rrrr�_check_end_pos3szEndPositionTests._check_end_poscCs|�t�||�|�dSry)r>r+�get_source_segment)r0r�r8Zcontentrrr�_check_content7szEndPositionTests._check_contentcCst�|�jdjS)Nr)r+rgrjr9r�rrr�_parse_value:szEndPositionTests._parse_valuecCsJd}|�|�}|�||jd�|�||jjdd�|�||jjd�dS)Nzlambda x, *y: NonerrrErV)r�r�rjr�rB)r0r�Zlamrrrr�?s

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)
rrvr+rgrjr�r�r��
annotationr��r0r�Zfdefrrr�
test_func_defFszEndPositionTests.test_func_defcCsNd}|�|�}|�||jd�|�||jdjd�|�||jdjd�dS)Nzfunc(x, y=2, **kw)rr�2r��kw)r�r�rrr9�r0r�r�rrrr�Vs

zEndPositionTests.test_callcCs0d}|�|�}|�||jd�|�|dd�dS)Nzx[0]()zx[0]r�r1)r�r�rr�r�rrr�test_call_noargs]s
z!EndPositionTests.test_call_noargscCsVtd���}t�|�jd}|�|dd�|�||jdd�|�||jdd�dS)Nz?
            class C(A, B):
                x: int = 0
        rr=�r��Bz
x: int = 0)rrvr+rgrjr�r�r_�r0r��cdefrrr�test_class_defcs
zEndPositionTests.test_class_defcCs.d}t�|�jd}|�||jdjd�dS)Nz$class S(metaclass=abc.ABCMeta): passrzabc.ABCMeta)r+rgrjr�rr9r�rrr�
test_class_kwmszEndPositionTests.test_class_kwcCs>td���}t�|�jd}|�|dd�|�|jdd�dS)Nzh
            x = """Some multi-line text.

            It goes on starting from same indent."""
        rr��(�rrvr+rgrjr�r9�r0r�r�rrr�test_multi_line_strrsz$EndPositionTests.test_multi_line_strcCs>td���}t�|�jd}|�|dd�|�|jdd�dS)NzB
            x = "first part" \
            "second part"
        rr=r'rrrrr�test_continued_str|s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�r=r�r�r�r%�r���r�zx = Nonezother()�x, yzraise RuntimeErrorrC)rrvr+rgrjr�r�rr*r��handlersr-)r0r�rwZ
while_loopZif_stmtZfor_loopZtry_stmtZ	pass_stmtrrr�test_suites�s$





zEndPositionTests.test_suitescCs,d}|�|�}|jdj}|�||d�dS)Nzx = f"abc {x + y} abc"r�zx + y)r�r8r9r��r0r�Zfstrr�rrr�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�Zarg_oneZarg_two)	rrvr�r8r9r�r�r�r�rrrr�test_fstring_multi_line�s	
z(EndPositionTests.test_fstring_multi_linecCs.td���}t�|�jd}|�|dd�dS)NzT
            from x.y.z import (
                a, b, c as c
            )
        rr�r�)rrvr+rgrjr�)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�)rrv�mapr�r�r9rkrmrl�eltsr�)r0�s1�s2�smZi1Zi2rqrrr�test_slices�szEndPositionTests.test_slicescCsZtd���}|�|�}|�|dd�|�||jd�|�||jd�|�||jjd�dS)NzF
            (1 * 2 + (3 ) +
                 4
            )
        r=r1�4z1 * 2 + (3 )�3)rrvr�r�r�r�r�)r0r�r�rrr�
test_binop�s
zEndPositionTests.test_binopcCsDtd���}t�|�jdj}|�|dd�|�||jdd�dS)Nz{
            if (one_condition and
                    (other_condition or yet_another_one)):
                pass
        rr=�,r�z"other_condition or yet_another_one)	rrvr+rgrjrr�r�r8)r0r�Zboprrrr��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�)rrvrr�r�r�)	r0rrZs3r�t1�t2Zt3Ztmrrr�test_tuples�szEndPositionTests.test_tuplescCs4d}|�|�}|�|||�|�||jdd�dS)Nz
func(x. y .z)rzx. y .z)r�r�r�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+rgrjr9r>r-rr�)r0r�r(rrrr�test_redundant_parenthesis
sz+EndPositionTests.test_redundant_parenthesisc	Cs�d}|D]�\}}|�|��~t�|�jdj}|�t|�j|�|�|||�d|}t�|�jdjj}|�t|�j|�|�|||�Wd�q1s�0YqdS)N))z( ( ( a ) ) ) ( )r
)z( ( ( a ) ) ) ( b )r
)z( ( ( a ) ) ) [ b ]r�)z( ( ( a ) ) ) . br�rr )	r^r+rgrjr9r>r-rr�)r0r�r�rr(rrrr�(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, }r=z{1, 2,}rr)r�r�rr7r8)r0rr�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]
        r=�%rZthings�stuffzcond.xr	)
rrvr�r�r��
generators�iter�elt�ifsr�)r0r��cmprrr�test_comprehensions3s
z$EndPositionTests.test_comprehensionscCsLtd���}t�|�jd}|�||jdjd�|�||jdjd�dS)NzT
            async def f():
                yield x
                await y
        rzyield xr�zawait y)rrvr+rgrjr�r9r�rrr�test_yield_await?sz!EndPositionTests.test_yield_awaitcCs<td���}td���}|�|�}|�t�||j�|�dS)NzD
            x = (
                a, b,
            ) + ()
        z;
            (
                a, b,
            )
        )rrvr�r>r+r�r�)r0�s_origZs_tupler�rrr�test_source_segment_multiIs
z*EndPositionTests.test_source_segment_multicCsBtd���}d}t�|�jd}|�tj||jddd�|�dS)Nuf
            class C:
                def fun(self) -> None:
                    "ЖЖЖЖЖ"
        u/    def fun(self) -> None:
        "ЖЖЖЖЖ"rT�Zpadded�rrvr+rgrjr>r�)r0r/�s_methodr�rrr�test_source_segment_paddedWs�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
r zw = 1r�zy = 1zz = 1)r+rgrjr�)r0r�r(r�rErVr�rrr�test_source_segment_endingscsz,EndPositionTests.test_source_segment_endingscCsBtd���}d}t�|�jd}|�tj||jddd�|�dS)Nzb
            class C:
              	  def fun(self) -> None:
              	      pass
        z+  	  def fun(self) -> None:
  	      passrTr1r2)r0r�r3r�rrr�test_source_segment_tabslsz)EndPositionTests.test_source_segment_tabscCstd}t�|�j\}}}}|`|`|`|`|�t�||��|�t�||��|�t�||��|�t�||��dS)Nzv = 1
w = 1
x = 1

y = 1
)	r+rgrjrr
rrrNr�)r0r�r(r�rErVrrr� test_source_segment_missing_infoxsz1EndPositionTests.test_source_segment_missing_infoN)"rr.rHr�r�r�r�r�r�r�r�r�rrrrr
rrrrr�rrr!r"r%r-r.r0r4r5r6r7rrrrr�-s>

	,	

	r�c@seZdZdd�ZdS)�NodeVisitorTestscs�G�fdd�dtj�}t�td��}|�}g�tjdd��(}t�ddt�|�|�Wd�n1sh0Y|�	�gd��|�	d	d
�|D�gd��dS)NcsHeZdZ�fdd�Z�fdd�Z�fdd�Z�fdd�Z�fd	d
�ZdS)z9NodeVisitorTests.test_old_constant_nodes.<locals>.Visitorcs��|jd|jf�dS)Nr�)rrr�r���logrr�	visit_Num�szCNodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_Numcs��|jd|jf�dS)Nr��rrr�r�r9rr�	visit_Str�szCNodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_Strcs��|jd|jf�dS)Nr�r<r�r9rr�visit_Bytes�szENodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_Bytescs��|jd|jf�dS)Nr�)rrr9r�r9rr�visit_NameConstant�szLNodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_NameConstantcs��|jddf�dS)Nr�.)rrr�r9rr�visit_Ellipsis�szHNodeVisitorTests.test_old_constant_nodes.<locals>.Visitor.visit_EllipsisN)rr.rHr;r=r>r?r@rr9rr�Visitor�s
rAz�            i = 42
            f = 4.25
            c = 4.25j
            s = 'string'
            b = b'bytes'
            t = True
            n = None
            e = ...
            T)�record�alwaysr#))r�r�r;)r=r�r�)r�r�r�)r�r�r�)r�r�r�)r1r�T)r�r�N)r�r�.cSsg|]}t|j��qSr)r�message)rr�rrrr	�r
z<NodeVisitorTests.test_old_constant_nodes.<locals>.<listcomp>)�+visit_Num is deprecated; add visit_ConstantrErEz+visit_Str is deprecated; add visit_Constantz-visit_Bytes is deprecated; add visit_Constant�4visit_NameConstant is deprecated; add visit_ConstantrFz0visit_Ellipsis is deprecated; add visit_Constant)
r+ZNodeVisitorrgr�warnings�catch_warnings�filterwarnings�DeprecationWarningZvisitr>)r0rArwZvisitorZwlogrr9r�test_old_constant_nodes�s
(
z(NodeVisitorTests.test_old_constant_nodesN)rr.rHrKrrrrr8�sr8c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ModuleStateTestscCs<d}d}d}t|||tjd�}t|||�}|�|tj�dS)Nzx + 1rfrR)�flags)r_r+r`rt�types�CodeType)r0rC�filenamerrdrrr�check_ast_module�sz!ModuleStateTests.check_ast_modulecCspt�tjdd��8tjd=ddl}tjd=ddl}|��Wd�n1sN0Y~~t��|��dS)N�_astr)r�	swap_item�sys�modulesrRrQrM)r0Zast1r�rrr�test_reload_module�s&z#ModuleStateTests.test_reload_modulec	s�t���fdd�}t�tjdd��ptjd=t�td|��:|��|�dtj�ddl	}|�
|��Wd�n1sz0YWd�n1s�0YdS)Ncs�tj|<�Sry)rTrU)r1r�r��Zlazy_modrr�	my_import�s
z4ModuleStateTests.test_sys_modules.<locals>.my_importrR�
__import__r)�objectrrSrTrUr��builtinsrQZassertNotInrRr�)r0rXrRrrWr�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)rrZrun_in_subinterpr>)r0rC�resrrr�test_subinterpreter�s
z$ModuleStateTests.test_subinterpreterN)rr.rHrQrVr\r^rrrrrL�s
rLcCs�tdkrdStjdd�dgkr�tdftdftdffD]F\}}t|d�|D]$}t�|d|�}td	t	|�f�qNtd
�q6td�t
�t��dS)N�__main__r�z-grPrQrRz_results = [rUz%r,�]zmain())
rrT�argvrWrYr[�printr+rgr�
SystemExit�unittest�main)Z
statementsrVZ	statementrhrrrres�
rer�)r��r�rr�r��r�rfNN)r��r�rr��)r�rhzmodule docstringNr[)r�rr�r'rr�)r\)r�r%r�r')r�rr��)r��r�r%r�rj)r�rkzfunction docstringN)r�rr�r��rW�r�r1r�r�rJNN)r\)r�r�r�r�)r�rr��)r��r�r�r�r%rN)r\)r�rr�rnrh)rW�r�r�r�r&r�NN)r\)r�r�r�ri)r�rr��)rW�r�r�r�r�r�NN)r\)r�rr�rq)r�rr��G)rl)rW�r�r%r�r�r�NN)rW�r�r�r�r�r�NN)rW�r��r�rrNN)rW)r��r�rjrNN)rW�r��#r��'r�NN)rW)r��)r�r;rNN)r�)r��+r��-r;N)rW)r��1r��7r�NN)r��r�r&r�rr�N)r��r�rnr��NNr�)r��r���r�r9)r��r�� )r��r��:r�rs)r�r�zdoc for f()Nr^)r�rr�r�C)r\)r�r�r�r)r�rr�r�)r��r�r%r�r�)r�r�zdocstring for class CN)r}rrrZr�)ZReturn�r�r�r�rn)r��r�r�r�rnr�Nrd�r�rr�r�)r}�r�r�r�r�r()ZDelrg�r}�r�rr�r�r(�rS)r�r�r�N�r�rr�r�r��r�rr�r�)r}r�rJr�)r}�r�r=r�r�r�r�r�)r}rmr�r�)r�rr�r%�r}�r�r�r�r=rJr�)r}�r�r�r�r�r�r�)r}ror�r�)ri�r�rr�r1r��r�)r��r�r�r�r1r�Nr|)r�rr�r�)r}r�r(r�)r}rtr(r�)r\)r�r&r�r�rm)r}rmr(r�ro)r}r�r(r�)r\)r�r�r�r%)r�rr�r1)r}r�rJr�)r\)r=r=r=r1)r�rr�r1)r})r�r�r�r1r�r�)r\)r�r=r�r1)r�rr1r1)r�rr1r1)r\)r1r=r1r1rq)r�rr�r)r�)r}r�rEr�)r}�r�r�r�r&rVr�)r\)r�r'r�r)r�rr��)r�)r}�r�r'r�r�r�r�)r}�r�rir�r�qr�)r\)r�rqr�r�rr
)r�r1r�r�)r})r�r1r�r�r�r�)r�)r�rnr�r�r�Nrurv)r}�r�r�r�rnr�r�)rx�r�rr�r�)r}�r�r�r�r�r(r�Nrz)r�rr�r�)rArTNrurT)rAr(Nr~r�r()r�r��r�r�r�N)r\rf)ZBreak�r�r&r�rn)r�rr�r)ZContinue)r�r&r�r)r�r�r�r�)r}r�rJr�)r}rmr�r�)r}r�r�r�)r�rr�r�)r�r�r�r%)r}r�rJr�)r}r�r�r�)r}r�r�r�)r\r�r�)r�rr&r�r�)r=r�r1r�)r})r�r�r�r1�Aar�)r})r�r�r�r%�Bbr�r~)r�r�r�r1)r})r�r�r�r1r�r�)r})r�r�r�r1r�r�)r})r�r�r�rZCcr�)r�rr��"r��r}r�rJr�)r}r�r�r�)r}r�r�r�)r}�r�rnr�rrEr�)r}rvr�r�)r})r��r�rxrkr�)r})r�r�r��!r�r�)r�r&r�r�)r}r�r(r�)r}r�r�r�)r}r�rEr�r�)r}r�rsr�)r}r�r�r�)r}�r�rr�r'rEr�)r}�r�rr�rir�r�)r�r�r�r�)r}rtr�r�)r}rurEr�ZAsyncFunctionDef)r�rr�ri)r��r=r�r=r)r�r�zasync functionN)r�r�r�riZAwait)r�r�r�ri)r}r�Z	somethingr�)r�rr�r�ZAsyncFor)r=r�r�r�)r})r=r&r=rrr�)r})r=rnr=rrbr�)r��r=rr=r�)r�r�r�N)r��r�r�r�r�)r�r�r=N)r�rr=rqZ	AsyncWith)r=r�r=rq)r�)r})r=rr=r'rJr�)r})r=rr=rir�r�)r��r=r�r=rq)r�r�r�N)r�r�r=N)r�r�r�r�)r�rmr=N)r�r�r�Nr�r�)r�r�r�r�)r�r=r�r�)r�r�r�N)r�r�r�Nr�)r})r=r=r=r�rbr�)r})r=r�r=r�r�r�)r}r�r�r�r�)r�rr�r')r\)r�r%r�r')r}�r�r�r�r1Zdeco1r�)r=r�r=r�)r})r=r�r=r1Zdeco2r�)r�r�r�r%)r})r�r�r�r1Zdeco3r�)r�r�r�N)r�rr�r)r\)r�r�r�r)r=rr=r')r\)r=r%r=r')r�r�r�r)r}�r�r�r�r�Zdecor�)r�r�r�r)r}rmrJr�)r}r�rJr�)r}r�r�r�)r�r�)r�)r�r�r�r�r�r�r�r�r�)r�r�)Z	NamedExpr)r�r�r�r�r�)r�rmr�N)r�rr�r�)�rWr�r�NN)rWr�rNN)rWr�rNN)r\)r�rwr�r�r�)rWr�rNN)rW�r�rqr�rwrNN)r\)r�r�r�rj)r�rr�r{)rW)r�r�r�r�r�NN)r\ry�r�ror�N)rWrur�NN)rW)r�rr�r�r�NN)r��r�r�r=N)r�r�r�N)rWrvr�NN)r�)r�r�r�r�r�Nr�)r\)r�rxr�r�)r�rr�r�)r\)r�r�r�r�)r�rr�r;)rW)r�rjr�rzr�NN)r\)r��&r�r;)r�rr�r)rW)r�r�r�r�r�NN)r\)r��$r�rrR)r�r�)r�r�r�r��r�r�r=N)r�rgr�r�)r��r}r�rJr�)r}rmr�r�)r�)r�r�r�r��r}r�r�r�)r�)rHr�)rI)r}r�r(r�r�)r�rr�r&)r�rpNN�r�r�r�N�r�r�r=N�r�rr�r=)r�r�NN)r�rr�r1)r�)r=r1r=r�r�N)r�)r�r�r�r&r=N)r}r�r�r�)r}r�rr�r�)r}r�rJr�r�)r}r�rJr�)r}r�r�r�)r}r�r�r�)r�rr�rwr�)r}rur�r�)r})r�r�r�rqr�r�r�r�)ZLt�r�ror�N)r}r�rr�)r�r�)r�)r�r�r�r)r}r�rr�r�)rb)r�r1r�r%r�r�)rb)r�r'r�rnN)r}r�rr�)r�r=r�r%)r�r�r�r%)r�r�rN)r�r�r�N)r�r�r�r�)r}rorJr�)r}r�r�r�)r�)r�r�r�N)r�)r�r�r�N)r��r�r�r�r�r�)r�)r�r�r�)r�)r�r=r�r�)r}r�r�r�)r}r�r�r�Nr�)r�)r}r�r(r�))r�r�r�N)r�r�r=N)r�r�r�N)r�r�)r�r�r�N)r�r�)r�r�r�r�r�rr�)r�r�)r�)r�r�r�r&)r}rorJr�r�r�)r�)r�rr�r�)r�r�r�N)r�rur=NNr�)r+r[r�r�rTrNrdrGrK�textwraprrrrrWrYr[ZTestCaser*r�rNr�r�r8r�rLrerXrZr\rrrr�<module>s
�K2xY2Q

,,.0,,L,"""
$&&


&&&<42&0D>:,,FHH6N.
.28806888<�F�&""@BB@BB@BB&"22�%

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