File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_unparse.cpython-312.pyc
�
h�eVk � �H � d Z ddlZddlZddlZddlZddlZddlZddlm Z d� Z
dZdZdZ
dZd Zd
ZdZdZd
ZdZdZdZdZdZ G d� de ej2 � Z G d� de� Z G d� de� Z G d� dej2 � Z G d� de� Zedk( r ej@ � yy)zTests for ast.unparse.� N)�ASTTestMixinc �x � t j | � 5 }|j � cddd� S # 1 sw Y yxY w)znRead and return the contents of a Python source file (as a
string), taking into account the file encoding.N)�tokenize�open�read)�filename�streams �8/opt/alt/python312/lib64/python3.12/test/test_unparse.py�read_pyfiler s0 � �
���x� � �F��{�{�}�� � �s �0�9zQdef 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
zetry:
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 �4 � e Zd Zd� Zefd�Zdd�Zdd�Zdd�Zy)�ASTTestCasec � � | j ||�� 5 t j |fi |��}t j |� }t j |fi |��}| j ||� d d d � y # 1 sw Y y xY w)N)�code1�ast_parse_kwargs)�subTest�ast�parse�unparse�assertASTEqual)�selfr �kwargs�ast1�code2�ast2s r
�check_ast_roundtripzASTTestCase.check_ast_roundtrip� sk � �
�\�\���\�
?� ,��9�9�U�-�f�-�D��K�K��%�E��9�9�U�-�f�-�D�����d�+� ,� ,� ,�s �AA1�1A:c � � | j |�� 5 | j |t j |� d d d � y # 1 sw Y y xY w)N)�node)r �assertRaisesr r )r r �raisess r
�
check_invalidzASTTestCase.check_invalid� s; � �
�\�\�t�\�
$� 9����f�c�k�k�4�8� 9� 9� 9�s �">�ANc �f � |xs |}t j t j |� � }||fS �N)r r r �r r r s r
�
get_sourcezASTTestCase.get_source� s, � ��������C�I�I�e�,�-���e�|�� c � � | j ||� \ }}| j ||�� 5 | j ||� d d d � y # 1 sw Y y xY w�N)r r )r% r �assertEqualr$ s r
�check_src_roundtripzASTTestCase.check_src_roundtrip� sK � ����u�e�4���u�
�\�\��U�\�
3� +����U�E�*� +� +� +�� �A�Ac � � | j ||� \ }}| j ||�� 5 | j ||� d d d � y # 1 sw Y y xY wr( )r% r �assertNotEqualr$ s r
�check_src_dont_roundtripz$ASTTestCase.check_src_dont_roundtrip� sK � ����u�e�4���u�
�\�\��U�\�
3� .�����u�-� .� .� .�r+ r# ) �__name__�
__module__�__qualname__r �
ValueErrorr! r% r* r. � r&