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_unparse.cpython-310.pyc
o

�9j_J�@s�dZddlZddlZddlZddlZddlZddlZdd�ZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZdZdZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�Zedkrce��dSdS)z>Tests for the unparse.py script in the Tools/parser directory.�NcCs6t�|��}|��Wd�S1swYdS)znRead and return the contents of a Python source file (as a
    string), taking into account the file encoding.N)�tokenize�open�read)�filename�stream�r�(/usr/lib/python3.10/test/test_unparse.py�read_pyfiles$�r	zQdef f():
    for x in range(10):
        break
    else:
        y = 2
    z = 3
zIdef g():
    while True:
        break
    else:
        y = 2
    z = 3
zQfrom . import fred
from .. import barney
from .australia import shrimp as prawns
zzdef f():
    x = 1
    def g():
        nonlocal x
        x = 2
        y = 7
        def h():
            nonlocal x, y
zOtry:
    1 / 0
except ZeroDivisionError as e:
    raise ArithmeticError from e
z@f1(arg)
@f2
class Foo: pass
z=if cond1:
    suite1
elif cond2:
    suite2
else:
    suite3
z,if cond1:
    suite1
elif cond2:
    suite2
zctry:
    suite1
except ex1:
    suite2
except ex2:
    suite3
else:
    suite4
finally:
    suite5
zwith f():
    suite1
zwith f() as x:
    suite1
z$with f() as x, g() as y:
    suite1
)�zclass foo:
    zdef foo():
    zasync def foo():
    c@sFeZdZdd�Zdd�Zefdd�Zddd	�Zdd
d�Zddd
�Z	dS)�ASTTestCasecCs|�t�|�t�|��dS�N)�assertEqual�ast�dump)�self�ast1�ast2rrr�assertASTEqualwszASTTestCase.assertASTEqualcKsn|j||d��&tj|fi|��}t�|�}tj|fi|��}|�||�Wd�dS1s0wYdS)N)�code1�ast_parse_kwargs)�subTestr�parse�unparser)rr�kwargsr�code2rrrr�check_ast_roundtripzs
"�zASTTestCase.check_ast_roundtripcCsB|j|d��|�|tj|�Wd�dS1swYdS)N)�node)r�assertRaisesrr)rr�raisesrrr�
check_invalid�s"�zASTTestCase.check_invalidNcCs |p|}t�t�|��}||fSr)rrr�rrrrrr�
get_source�szASTTestCase.get_sourcecC�P|�||�\}}|j||d��|�||�Wd�dS1s!wYdS�N)rr)r!rr
r rrr�check_src_roundtrip��"�zASTTestCase.check_src_roundtripcCr"r#)r!r�assertNotEqualr rrr�check_src_dont_roundtrip�r%z$ASTTestCase.check_src_dont_roundtripr)
�__name__�
__module__�__qualname__rr�
ValueErrorrr!r$r'rrrrrvs

rc@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�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]S)^�UnparseTestCasecC�,|�d�|�d�|�d�|�d�dS)Nz
f'{f"{0}"*3}'z
f'{f"{y}"*3}'zf''zf"""'end' "quote\""""�r�rrrr�
test_fstrings�s


zUnparseTestCase.test_fstringscCsJ|�d�|�d�|�d�|�d�|�d�|�d�|�d�dS)Nzf'''{"'"}'''�%f'''-{f"""*{f"+{f'.{x}.'}+"}*"""}-'''z4f'''-{f"""*{f"+{f'.{x}.'}+"}*"""}-'single quote\''''zf"""{'''
'''}"""zf"""{g('''
''')}"""z	f"a\r\nb"�f"\u2028{'x'}"r.r/rrr�test_fstrings_complicated�s





z)UnparseTestCase.test_fstrings_complicatedcC�"|�d�|�d�|�d�dS)Nzu'foo'zr'foo'zb'foo'r.r/rrr�test_strings��

zUnparseTestCase.test_stringscC�|�d�dS)Nzdel x, y, zr.r/rrr�test_del_statement��z"UnparseTestCase.test_del_statementcC�|�d�|�d�dS)Nz45 << 2z13 >> 7r.r/rrr�test_shifts��
zUnparseTestCase.test_shiftscC�|�t�dSr)r�for_elser/rrr�
test_for_else�r9zUnparseTestCase.test_for_elsecCr=r)r�
while_elser/rrr�test_while_else�r9zUnparseTestCase.test_while_elsecC�6|�d�|�d�|�d�|�d�|�d�dS)Nz(-1)**7z(-1.)**8z(-1j)**6znot True or FalsezTrue or not Falser.r/rrr�test_unary_parens��




z!UnparseTestCase.test_unary_parenscCr7)Nz3 .__abs__()r.r/rrr�test_integer_parens�r9z#UnparseTestCase.test_integer_parenscCr-)N�1e1000z-1e1000�1e1000jz-1e1000jr.r/rrr�test_huge_float��


zUnparseTestCase.test_huge_floatc	Cs.|�t�t�tjtd�d���t�d��dS)N�nan��valuez1e1000 - 1e1000)rrrr�Constant�floatr/rrr�test_nan�s�zUnparseTestCase.test_nancCs |�td��|�td��dS)Ni�l����)r�strr/rrr�test_min_int�szUnparseTestCase.test_min_intcCr-)N�7jz-7j�0jz-0jr.r/rrr�test_imaginary_literals�rIz'UnparseTestCase.test_imaginary_literalscCr7)Nz(lambda: int)()r.r/rrr�test_lambda_parentheses�r9z'UnparseTestCase.test_lambda_parenthesescCr:)Nz
1 < 4 <= 5za is b is c is not dr.r/rrr�test_chained_comparisons�r<z(UnparseTestCase.test_chained_comparisonscCs||�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�dS)
Nz
def f(): passzdef f(a): passzdef f(b = 2): passzdef f(a, b): passzdef f(a, b = 2): passzdef f(a = 5, b = 2): passzdef f(*, a = 1, b = 2): passzdef f(*, a = 1, b): passzdef f(*, a, b = 2): passz&def f(a, b = None, *, c, **kwds): passz'def f(a=2, *args, c=5, d, **kwds): passzdef f(*args, **kwargs): passr.r/rrr�test_function_arguments�s










z'UnparseTestCase.test_function_argumentscCr=r)r�relative_importr/rrr�test_relative_import�r9z$UnparseTestCase.test_relative_importcCr=r)r�nonlocal_exr/rrr�
test_nonlocal�r9zUnparseTestCase.test_nonlocalcCr=r)r�
raise_fromr/rrr�test_raise_from�r9zUnparseTestCase.test_raise_fromcCr7)Nzb'123'r.r/rrr�
test_bytes�r9zUnparseTestCase.test_bytescCrB)Nzdef f(a : int): passzdef f(a: int = 5): passzdef f(*args: [int]): passzdef f(**kwargs: dict): passzdef f() -> None: passr.r/rrr�test_annotations�rDz UnparseTestCase.test_annotationscCr7)Nz{'a', 'b', 'c'}r.r/rrr�test_set_literalr9z UnparseTestCase.test_set_literalc	Cs*|�t�t�tjgd���t�d��dS)N)�eltsz{*()})rrrr�Setr/rrr�test_empty_sets�zUnparseTestCase.test_empty_setcCr7)Nz{x for x in range(5)}r.r/rrr�test_set_comprehensionr9z&UnparseTestCase.test_set_comprehensioncCr7)Nz{x: x*x for x in range(10)}r.r/rrr�test_dict_comprehensionr9z'UnparseTestCase.test_dict_comprehensioncCr=r)r�class_decoratorr/rrr�test_class_decoratorsr9z%UnparseTestCase.test_class_decoratorscCr7)Nz(class A(metaclass=type, *[], **{}): passr.r/rrr�test_class_definitionr9z%UnparseTestCase.test_class_definitioncCs|�t�|�t�dSr)r�elif1�elif2r/rrr�
test_elifsr<zUnparseTestCase.test_elifscCr=r)r�try_except_finallyr/rrr�test_try_except_finallyr9z'UnparseTestCase.test_try_except_finallycCr-)Nza, *b, c = seqza, (*b, c) = seqza, *b[0], c = seqza, *(b, c) = seqr.r/rrr�test_starred_assignmentrIz'UnparseTestCase.test_starred_assignmentcCr=r)r�with_simpler/rrr�test_with_simple$r9z UnparseTestCase.test_with_simplecCr=r)r�with_asr/rrr�test_with_as'r9zUnparseTestCase.test_with_ascCr=r)r�with_two_itemsr/rrr�test_with_two_items*r9z#UnparseTestCase.test_with_two_itemscCr:)Nz{**{'y': 2}, 'x': 1}z{**{'y': 2}, **{'x': 1}}r.r/rrr�test_dict_unpacking_in_dict-s
z+UnparseTestCase.test_dict_unpacking_in_dictcCs�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�dS)Nza[i]za[i,]za[i, j]za[(*a,)]z	a[(a:=b)]za[(a:=b,c)]za[()]za[i:j]za[:j]za[i:]za[i:j:k]za[:j:k]za[i::k]za[i:j,]z	a[i:j, k]r.r/rrr�test_slices2s













zUnparseTestCase.test_slicescCs |�tjdtjdd�d��dS)N�X)�id)�exc�cause)rr�Raise�Namer/rrr�test_invalid_raiseC� z"UnparseTestCase.test_invalid_raisecCs |�tjtjdd�gd��dS)N�drK)�values)rr�	JoinedStrrMr/rrr�test_invalid_fstring_constantFr~z-UnparseTestCase.test_invalid_fstring_constantcCs(|�tjtjddd�td�dd��dS)N�a�rL�kind�Y)rL�
conversion�format_spec)rr�FormattedValuerM�ordr/rrr�test_invalid_fstring_conversionIs��z/UnparseTestCase.test_invalid_fstring_conversioncCs|�tjtjdd�d��dS)Nz\\rK)rrr�rMr/rrr�test_invalid_fstring_backslashRsz.UnparseTestCase.test_invalid_fstring_backslashcCs|�tjdd��dS)NrK)rr�	YieldFromr/rrr�test_invalid_yield_fromUsz'UnparseTestCase.test_invalid_yield_fromcCsZtjdtjdd�gd�}|�t�|�d�tjdtjdd�gdd�}|�t�|�d�dS)N�mod�x)�name)�module�nameszfrom mod import x)r�r��level)r�
ImportFrom�aliasr
r)r�treerrr�test_import_from_level_noneXsz+UnparseTestCase.test_import_from_level_nonecCs$d}|D]}|�d|�d��qdS)N)
zthis ends with double quote"z"this includes a """triple quote"""�
z\r�	z\t�
z\nz	
\r	\t
\nz$""">>> content = """blabla""" <<<"""z	foo\n\x00z' \'\'\'""" ""\'\' \'u🐍⛎𩸽üéş^\\X\\BB⟿z'''r.)r�
docstrings�	docstringrrr�test_docstrings^s�zUnparseTestCase.test_docstringscCs0|�tjddd�d�|�tjddd�d�dS)N)�r�z(1,))r���z	(1, 2, 3))r$rrMr/rrr�test_constant_tuplesrs�z$UnparseTestCase.test_constant_tuplescC�dD]	}|j|dd�qdS)N)z	() -> intz(int, int) -> intz=(Callable[complex], More[Complex(call.to_typevar())]) -> None�	func_type)�moder.)r�
function_typerrr�test_function_typexs�z"UnparseTestCase.test_function_typecCr�)N)z
a = 5 # type:za = 5 # type: intza = 5 # type: int and morez!def x(): # type: () -> None
	passz.def x(y): # type: (int) -> None and more
	passz'async def x(): # type: () -> None
	passz4async def x(y): # type: (int) -> None and more
	passzfor x in y: # type: int
	passz#async for x in y: # type: int
	passzwith x(): # type: int
	passz!async with x(): # type: int
	passT��
type_commentsr.�r�	statementrrr�test_type_comments�s
�z"UnparseTestCase.test_type_commentscCr�)N)
za = 5 # type: ignoreza = 5 # type: ignore and morezdef x(): # type: ignore
	passz'def x(y): # type: ignore and more
	passz#async def x(): # type: ignore
	passz-async def x(y): # type: ignore and more
	passz for x in y: # type: ignore
	passz&async for x in y: # type: ignore
	passzwith x(): # type: ignore
	passz$async with x(): # type: ignore
	passTr�r.r�rrr�test_type_ignore�s�z UnparseTestCase.test_type_ignoreN)1r(r)r*r0r3r5r8r;r?rArCrErHrOrQrTrUrVrWrYr[r]r^r_r`rcrdrergrhrkrmrnrprrrtrurvr}r�r�r�r�r�r�r�r�r�r�rrrrr,�s^
	r,c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�CosmeticTestCasezATest if there are cosmetic issues caused by unnecessary additionscCs|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�|�d
�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�dS)Nz(a := b)zawait xz
x if x else yzlambda x: xz1 + 1z	1 + 2 / 3z(1 + 2) / 3z(1 + 2) * 3 + 4 * (5 + 2)z(1 + 2) * 3 + 4 * (5 + 2) ** 2z~xzx and yz
x and y and zzx and (y and x)z(x and y) and zz(x ** y) ** z ** qzx >> yzx << yzx >> y and x >> zzx + y - z * q ^ t ** kzP * V if P and V else n * R * Tz"lambda P, V, n: P * V == n * R * Tzflag & (other | foo)z
not x == yzx == (not y)zyield xzyield from xzcall((yield x))zreturn x + (yield x)�r$r/rrr�test_simple_expressions_parens�s8


























z/CosmeticTestCase.test_simple_expressions_parenscCsh|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�dS)Nzclass X:
    passzclass X(A):
    passzclass X(A, B, C, D):
    passzclass X(x=y):
    passzclass X(metaclass=z):
    passzclass X(x=y, z=d):
    passzclass X(A, x=y):
    passzclass X(A, **kw):
    passzclass X(*args):
    passz"class X(*args, **kwargs):
    passr�r/rrr�test_class_bases_and_keywords�s








z.CosmeticTestCase.test_class_bases_and_keywordscCrB)Nr1r2zf'{x}\n'zf'''{"""
"""}\n'''zf'''{f"""{x}
"""}\n'''r�r/rrrr0�rDzCosmeticTestCase.test_fstringscCs.d}tD]}|D]}|�|�|���qqdS)N)
z"""simple doc string"""z7"""A more complex one
            with some newlines"""z,"""Foo bar baz

            empty newline"""z"""With some 	"""z"""Foo "bar" baz """z"""\r"""z""""""z	"""'''"""z"""''''''"""u""""🐍⛎𩸽üéş^\\X\\BB⟿"""z"""end in single 'quote'"""z'''end in double "quote"'''z#"""almost end in double "quote".""")�docstring_prefixesr$)rr��prefixr�rrrr��s��z CosmeticTestCase.test_docstringscCs<d}tD]}|D]}|�|��}|�|�|�|�qqdS)N)za = """false"""z("""false""" + """unless its optimized"""z1 + 1
"""false"""z"f"""no, top level but f-fstring""")r�rr')r�docstrings_negativer��negative�srcrrr�test_docstrings_negative_cases�s
��z/CosmeticTestCase.test_docstrings_negative_casescCs8dD]
}|�|�d��qdD]
}|�|�d��qdS)N)�+�-�~�1)�notz 1r�)rr�rrr�test_unary_op_factor�s
�z%CosmeticTestCase.test_unary_op_factorcCr4)Nza[1]za[1, 2]z
a[(1, *a)]r�r/rrrrvr6zCosmeticTestCase.test_slicesN)r(r)r*�__doc__r�r�r0r�r�r�rvrrrrr��sr�c@sLeZdZdZe�e�jdZeedfZ	hd�Z
dZedd��Z
dd	�ZdS)
�DirectoryTestCasez:Test roundtrip behaviour on all files in Lib and Lib/test.z..�test>�test_ast.py�
test_patma.py�test_syntax.py�test_compile.py�test_fstring.py�test_grammar.py�test_asdl_parser.pyNcsd�jdur�jSdd��jD�}tj�d�s-�fdd�|D�}tt�|d��}t||B�}|�_|S)NcSs0g|]}|�d�D]}|j�d�s	|���q	qS)z*.py�bad)�globr��
startswith�resolve)�.0�	directory�itemrrr�
<listcomp>s�
��z3DirectoryTestCase.files_to_test.<locals>.<listcomp>�cpucsh|]
}|j�jvr|�qSr)r��run_always_files)r�r���clsrr�	<setcomp>$s�z2DirectoryTestCase.files_to_test.<locals>.<setcomp>�
)	�_files_to_test�test_directoriesr��support�is_resource_enabled�set�random�sample�list)r��items�tests_to_run_alwaysrr�r�
files_to_tests
�zDirectoryTestCase.files_to_testc	Csj|��D].}tjjrtd|�����|j|d��t|�}|�|�Wd�n1s-wYqdS)NzTesting )r)	r�r�r��verbose�print�absoluterr	r)rr��sourcerrr�
test_files3s���zDirectoryTestCase.test_files)r(r)r*r��pathlib�Path�__file__�parent�lib_dirr�r�r��classmethodr�r�rrrrr�	s
r��__main__)r��unittest�test.supportr�r�r�rrr	r>r@rXrZr\rfrirjrlrorqrsr��TestCaserr,r�r�r(�mainrrrr�<module>s<			
i4�

Youez - 2016 - github.com/yon3zu
LinuXploit