HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/test/test_tools/__pycache__/test_unparse.cpython-38.opt-2.pyc
U

1D�gQ#�	@s�ddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZe�ej�
e
d�Zej�e��ddlZW5QRXdd�ZdZdZdZd	Zd
ZdZdZd
ZdZdZdZdZGdd�dej�Z Gdd�de �Z!Gdd�de �Z"e#dkr�e�$�dS)�N)�basepath�toolsdir�skip_if_missing�parserc	CsLt|d��}t�|j�d}W5QRXt|d|d��}|��}W5QRX|S)N�rbr�r)�encoding)�open�tokenize�detect_encoding�readline�read)�filenameZpyfiler�source�r�;/opt/cppython/lib/python3.8/test/test_tools/test_unparse.py�read_pyfiles
rzQdef 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
c@seZdZdd�Zddd�ZdS)�ASTTestCasecCs|�t�|�t�|��dS�N)ZassertEqual�ast�dump)�self�ast1�ast2rrr�assertASTEqual{szASTTestCase.assertASTEqual�internalcCsLt||dtj�}t��}t�||�|��}t||dtj�}|�||�dS)N�exec)	�compilerZ
PyCF_ONLY_AST�io�StringIO�unparseZUnparser�getvaluer)r�code1rrZunparse_buffer�code2rrrr�check_roundtrip~szASTTestCase.check_roundtripN)r)�__name__�
__module__�__qualname__rr$rrrrrzsrc@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"dAS)B�UnparseTestCasecCs|�d�|�d�dS)Nz
f'{f"{0}"*3}'z
f'{f"{y}"*3}'�r$�rrrr�
test_fstrings�s
zUnparseTestCase.test_fstringscCs"|�d�|�d�|�d�dS)Nzu'foo'zr'foo'zb'foo'r)r*rrr�test_strings�s

zUnparseTestCase.test_stringscCs|�d�dS)Nzdel x, y, zr)r*rrr�test_del_statement�sz"UnparseTestCase.test_del_statementcCs|�d�|�d�dS)Nz45 << 2z13 >> 7r)r*rrr�test_shifts�s
zUnparseTestCase.test_shiftscCs|�t�dSr)r$�for_elser*rrr�
test_for_else�szUnparseTestCase.test_for_elsecCs|�t�dSr)r$�
while_elser*rrr�test_while_else�szUnparseTestCase.test_while_elsecCs6|�d�|�d�|�d�|�d�|�d�dS)Nz(-1)**7z(-1.)**8z(-1j)**6znot True or FalsezTrue or not Falser)r*rrr�test_unary_parens�s




z!UnparseTestCase.test_unary_parenscCs|�d�dS)Nz3 .__abs__()r)r*rrr�test_integer_parens�sz#UnparseTestCase.test_integer_parenscCs,|�d�|�d�|�d�|�d�dS)NZ1e1000z-1e1000Z1e1000jz-1e1000jr)r*rrr�test_huge_float�s


zUnparseTestCase.test_huge_floatcCs |�td��|�td��dS)Ni�l����)r$�strr*rrr�test_min_int�szUnparseTestCase.test_min_intcCs,|�d�|�d�|�d�|�d�dS)NZ7jz-7jZ0jz-0jr)r*rrr�test_imaginary_literals�s


z'UnparseTestCase.test_imaginary_literalscCs|�d�dS)Nz(lambda: int)()r)r*rrr�test_lambda_parentheses�sz'UnparseTestCase.test_lambda_parenthesescCs|�d�|�d�dS)Nz
1 < 4 <= 5za is b is c is not dr)r*rrr�test_chained_comparisons�s
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_argumentscCs|�t�dSr)r$�relative_importr*rrr�test_relative_import�sz$UnparseTestCase.test_relative_importcCs|�t�dSr)r$�nonlocal_exr*rrr�
test_nonlocal�szUnparseTestCase.test_nonlocalcCs|�t�dSr)r$�
raise_fromr*rrr�test_raise_from�szUnparseTestCase.test_raise_fromcCs|�d�dS)Nzb'123'r)r*rrr�
test_bytes�szUnparseTestCase.test_bytescCs6|�d�|�d�|�d�|�d�|�d�dS)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�s




z UnparseTestCase.test_annotationscCs|�d�dS)Nz{'a', 'b', 'c'}r)r*rrr�test_set_literal�sz UnparseTestCase.test_set_literalcCs|�d�dS)Nz{x for x in range(5)}r)r*rrr�test_set_comprehension�sz&UnparseTestCase.test_set_comprehensioncCs|�d�dS)Nz{x: x*x for x in range(10)}r)r*rrr�test_dict_comprehension�sz'UnparseTestCase.test_dict_comprehensioncCs|�t�dSr)r$�class_decoratorr*rrr�test_class_decorators�sz%UnparseTestCase.test_class_decoratorscCs|�d�dS)Nz(class A(metaclass=type, *[], **{}): passr)r*rrr�test_class_definition�sz%UnparseTestCase.test_class_definitioncCs|�t�|�t�dSr)r$�elif1�elif2r*rrr�
test_elifs�s
zUnparseTestCase.test_elifscCs|�t�dSr)r$�try_except_finallyr*rrr�test_try_except_finally�sz'UnparseTestCase.test_try_except_finallycCs,|�d�|�d�|�d�|�d�dS)Nza, *b, c = seqza, (*b, c) = seqza, *b[0], c = seqza, *(b, c) = seqr)r*rrr�test_starred_assignment�s


z'UnparseTestCase.test_starred_assignmentcCs|�t�dSr)r$�with_simpler*rrr�test_with_simple�sz UnparseTestCase.test_with_simplecCs|�t�dSr)r$�with_asr*rrr�test_with_asszUnparseTestCase.test_with_ascCs|�t�dSr)r$�with_two_itemsr*rrr�test_with_two_itemssz#UnparseTestCase.test_with_two_itemscCs|�d�|�d�dS)Nz{**{'y': 2}, 'x': 1}z{**{'y': 2}, **{'x': 1}}r)r*rrr�test_dict_unpacking_in_dicts
z+UnparseTestCase.test_dict_unpacking_in_dictcCs||�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�|�d�dS)
Nza[i]za[i,]za[i, j]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_subscripts










zUnparseTestCase.test_subscriptN)#r%r&r'r+r,r-r.r0r2r3r4r5r7r8r9r:r;r=r?rArBrCrDrErFrHrIrLrNrOrQrSrUrVrWrrrrr(�s@r(c@s6eZdZdZdej�dd�fZedd��Z	dd�Z
dS)�DirectoryTestCaseNZLib�testcCs�|jdk	r|jSg}|jD]J}tj�t|�}t�|�D],}|�d�r6|�d�s6|�	tj�||��q6qt
j�d�s~t
�|d�}||_|S)Nz.pyZbadZcpu�
)�NAMES�test_directories�os�path�joinr�listdir�endswith�
startswith�appendrY�supportZis_resource_enabled�random�sample)�cls�names�dZtest_dir�nrrr�	get_names"s

zDirectoryTestCase.get_namesc
Cs~|��}|D]l}tjjr$td|�tj�|�dkrNtjjrtd|�d��q|j|d��t	|�}|�
|�W5QRXqdS)Nz
Testing %s)ztest_fstring.pyz	Skipping z: see issue 28002)r)rkrYrd�verbose�printr]r^�basenameZsubTestrr$)rrhrrrrr�
test_files6szDirectoryTestCase.test_files)r%r&r'r[r]r^r_r\�classmethodrkrorrrrrXs

rX�__main__)%ZunittestZtest.supportrYrr]rer
rZtest.test_toolsrrrr^r_Zparser_pathrdZ
DirsOnSysPathr rr/r1r<r>r@rGrJrKrMrPrRrTZTestCaserr(rXr%�mainrrrr�<module>s<				
0