+
    Bi                     X   R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
 R tRtRtRtRtRtR	tR
tRtRtRtRtRtRtRt ! R R]
]P4                  4      t ! R R]4      t ! R R]4      t ! R R]P4                  4      t ! R R]4      t] R8X  d   ]PB                  ! 4        R# R# )zTests for ast.unparse.N)ASTTestMixinc                    \         P                  ! V 4      ;_uu_ 4       pVP                  4       uuRRR4       #   + '       g   i     R# ; i)zjRead and return the contents of a Python source file (as a
string), taking into account the file encoding.N)tokenizeopenread)filenamestreams   & (/usr/lib/python3.14/test/test_unparse.pyread_pyfiler
      s-     
x	 	 F{{} 
!	 	 	 s	   :A	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
zetry:
    suite1
except* ex1:
    suite2
except* ex2:
    suite3
else:
    suite4
finally:
    suite5
zwith f():
    suite1
zwith f() as x:
    suite1
z$with f() as x, g() as y:
    suite1
c                   P   a  ] tR t^t o R t]3R ltRR ltRR ltRR lt	Rt
V tR# )	ASTTestCasec                   V P                  WR 7      ;_uu_ 4        \        P                  ! V3/ VB p\        P                  ! V4      p\        P                  ! V3/ VB pV P	                  W54       RRR4       R#   + '       g   i     R# ; i))code1ast_parse_kwargsN)subTestastparseunparseassertASTEqual)selfr   kwargsast1code2ast2s   &&,   r	   check_ast_roundtripASTTestCase.check_ast_roundtrip   se    \\\??99U-f-DKK%E99U-f-D+	 @???s   AA;;B	c                    V P                  VR 7      ;_uu_ 4        V P                  V\        P                  V4       RRR4       R#   + '       g   i     R# ; i))nodeN)r   assertRaisesr   r   )r   r   raisess   &&&r	   check_invalidASTTestCase.check_invalid   s8    \\t\$$fckk48 %$$$s   "AA	Nc                v    T;'       g    Tp\         P                  ! \         P                  ! V3/ VB 4      pW3# N)r   r   r   r   r   r   r   s   &&&,r	   
get_sourceASTTestCase.get_source   s1    CIIe6v67|    c                    V P                   ! W3/ VB w  rV P                  WR 7      ;_uu_ 4        V P                  W!4       RRR4       R#   + '       g   i     R# ; i)r   r   N)r%   r   assertEqualr$   s   &&&,r	   check_src_roundtripASTTestCase.check_src_roundtrip   sE    u>v>\\\33U* 4333s   AA	c                    V P                  W4      w  rV P                  WR 7      ;_uu_ 4        V P                  W!4       RRR4       R#   + '       g   i     R# ; ir)   )r%   r   assertNotEqual)r   r   r   s   &&&r	   check_src_dont_roundtrip$ASTTestCase.check_src_dont_roundtrip   s@    u4\\\33- 4333s   A

A	 r#   )__name__
__module____qualname____firstlineno__r   
ValueErrorr    r%   r+   r/   __static_attributes____classdictcell____classdict__s   @r	   r   r      s(     , *4 9
+
. .r'   r   c                   ^  a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R t"R  t#R! t$R" t%R# t&R$ t'R% t(R& t)R' t*R( t+R) t,R* t-R+ t.R, t/R- t0R. t1R/ t2R0 t3R1 t4R2 t5R3 t6R4 t7R5 t8R6t9V t:R7# )8UnparseTestCasec                &   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R	4       V P                  R
4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )zf'a'zf'{{}}'zf'{{5}}'z	f'{{5}}5'z	f'X{{}}X'zf'{a}'zf'{ {1:2}}'zf'a{a}a'zf'a{a}{a}a'zf'a{a}a{a}a'zf'{a!r}x{a!s}12{{}}{a!a}'z	f'{a:10}'zf'{a:100_000{10}}'zf'{a!r:10}'zf'{a:a{b}10}'zRf'a{b}{c!s}{d!r}{e!a}{f:a}{g:a{b}}{h!s:a}{j!s:{a}b}{k!s:a{b}c}{l!a:{b}c{d}}{x+y=}'Nr   r   s   &r	   test_fstringsUnparseTestCase.test_fstrings   s      (  +  ,  -  -  *  /  ,  /  0  !<=  -  !56  /  1  <	
r'   c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       R# )zf'{f"{0}"*3}'zf'{f"{y}"*3}'zf''zf"""'end' "quote\""""Nr>   r?   s   &r	   test_fstrings_special_chars+UnparseTestCase.test_fstrings_special_chars   s=      !56  !56  +  !=>r'   c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )zf'''{"'"}'''%f'''-{f"""*{f"+{f'.{x}.'}+"}*"""}-'''z4f'''-{f"""*{f"+{f'.{x}.'}+"}*"""}-'single quote\''''zf"""{'''
'''}"""zf"""{g('''
''')}"""z	f"a\r\nb"f"\u2028{'x'}"Nr>   r?   s   &r	   test_fstrings_complicated)UnparseTestCase.test_fstrings_complicated   sk      !34  !RS  !bc  !:;  !=>  !23  !67r'   c                J    V P                  R 4       V P                  R4       R# )z0f" something { my_dict["key"] } something else "z!f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}"Nr>   r?   s   &r	   test_fstrings_pep701$UnparseTestCase.test_fstrings_pep701   s       !ST  !DEr'   c                l    V P                  R 4       V P                  R4       V P                  R4       R# )zt'foo'zt'foo {bar}'zt'foo {bar!s:.2f}'Nr>   r?   s   &r	   test_tstringsUnparseTestCase.test_tstrings   s-      *  0  !56r'   c                l    V P                  R 4       V P                  R4       V P                  R4       R# )zu'foo'zr'foo'zb'foo'Nr>   r?   s   &r	   test_stringsUnparseTestCase.test_strings   s,      *  *  *r'   c                (    V P                  R 4       R# )zdel x, y, zNr>   r?   s   &r	   test_del_statement"UnparseTestCase.test_del_statement   s      /r'   c                J    V P                  R 4       V P                  R4       R# )z45 << 2z13 >> 7Nr>   r?   s   &r	   test_shiftsUnparseTestCase.test_shifts   s      +  +r'   c                0    V P                  \        4       R # r#   )r   for_elser?   s   &r	   test_for_elseUnparseTestCase.test_for_else   s      *r'   c                0    V P                  \        4       R # r#   )r   
while_elser?   s   &r	   test_while_elseUnparseTestCase.test_while_else         ,r'   c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )z(-1)**7z(-1.)**8z(-1j)**6znot True or FalsezTrue or not FalseNr>   r?   s   &r	   test_unary_parens!UnparseTestCase.test_unary_parens   sJ      +  ,  ,  !45  !45r'   c                (    V P                  R 4       R# )z3 .__abs__()Nr>   r?   s   &r	   test_integer_parens#UnparseTestCase.test_integer_parens   s      0r'   c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       R# )1e1000z-1e10001e1000jz-1e1000jNr>   r?   s   &r	   test_huge_floatUnparseTestCase.test_huge_float   s:      *  +  +  ,r'   c                    V P                  \        P                  ! \        P                  ! \        P                  ! \        R 4      R7      4      4      \        P                  ! R4      4       R# )nanvaluez1e1000 - 1e1000N)r   r   r   r   Constantfloatr?   s   &r	   test_nanUnparseTestCase.test_nan   s?    IIckk#,,U5\"BCDII'(	
r'   c                n    V P                  \        R4      4       V P                  \        R4      4       R# )   Ni   l         )r   strr?   s   &r	   test_min_intUnparseTestCase.test_min_int   s&      Z1  Z1r'   c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       R# )7jz-7j0jz-0jNr>   r?   s   &r	   test_imaginary_literals'UnparseTestCase.test_imaginary_literals   s:      &  '  &  'r'   c                (    V P                  R 4       R# )z(lambda: int)()Nr>   r?   s   &r	   test_lambda_parentheses'UnparseTestCase.test_lambda_parentheses        !23r'   c                J    V P                  R 4       V P                  R4       R# )z
1 < 4 <= 5za is b is c is not dNr>   r?   s   &r	   test_chained_comparisons(UnparseTestCase.test_chained_comparisons  s      .  !78r'   c                   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R	4       V P                  R
4       V P                  R4       R# )zdef f(): passzdef f(a): passzdef f(b = 2): passzdef f(a, b): passzdef f(a, b = 2): passzdef f(a = 5, b = 2): passzdef f(*, a = 1, b = 2): passzdef f(*, a = 1, b): passzdef f(*, a, b = 2): passz&def f(a, b = None, *, c, **kwds): passz'def f(a=2, *args, c=5, d, **kwds): passzdef f(*args, **kwargs): passNr>   r?   s   &r	   test_function_arguments'UnparseTestCase.test_function_arguments  s      1  !12  !56  !45  !89  !<=  !?@  !;<  !;<  !IJ  !JK  !?@r'   c                0    V P                  \        4       R # r#   )r   relative_importr?   s   &r	   test_relative_import$UnparseTestCase.test_relative_import        1r'   c                0    V P                  \        4       R # r#   )r   nonlocal_exr?   s   &r	   test_nonlocalUnparseTestCase.test_nonlocal        -r'   c                0    V P                  \        4       R # r#   )r   
raise_fromr?   s   &r	   test_raise_fromUnparseTestCase.test_raise_from  ra   r'   c                (    V P                  R 4       R# )zb'123'Nr>   r?   s   &r	   
test_bytesUnparseTestCase.test_bytes"  s      *r'   c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )zdef f(a : int): passzdef f(a: int = 5): passzdef f(*args: [int]): passzdef f(**kwargs: dict): passzdef f() -> None: passNr>   r?   s   &r	   test_annotations UnparseTestCase.test_annotations%  sM      !78  !:;  !<=  !>?  !89r'   c                (    V P                  R 4       R# )z{'a', 'b', 'c'}Nr>   r?   s   &r	   test_set_literal UnparseTestCase.test_set_literal,  r   r'   c           
         V P                  \        P                  ! \        P                  ! \        P                  ! . R 7      4      4      \        P                  ! R4      4       R# ))eltsz{*()}N)r   r   r   r   Setr?   s   &r	   test_empty_setUnparseTestCase.test_empty_set/  s:    IIckk#''r"234IIg	
r'   c                (    V P                  R 4       R# )z{x for x in range(5)}Nr>   r?   s   &r	   test_set_comprehension&UnparseTestCase.test_set_comprehension5  s      !89r'   c                (    V P                  R 4       R# )z{x: x*x for x in range(10)}Nr>   r?   s   &r	   test_dict_comprehension'UnparseTestCase.test_dict_comprehension8  s      !>?r'   c                0    V P                  \        4       R # r#   )r   class_decoratorr?   s   &r	   test_class_decorators%UnparseTestCase.test_class_decorators;  r   r'   c                (    V P                  R 4       R# )z(class A(metaclass=type, *[], **{}): passNr>   r?   s   &r	   test_class_definition%UnparseTestCase.test_class_definition>  s      !KLr'   c                Z    V P                  \        4       V P                  \        4       R # r#   )r   elif1elif2r?   s   &r	   
test_elifsUnparseTestCase.test_elifsA  s      '  'r'   c                0    V P                  \        4       R # r#   )r   try_except_finallyr?   s   &r	   test_try_except_finally'UnparseTestCase.test_try_except_finallyE  s      !34r'   c                0    V P                  \        4       R # r#   )r   try_except_star_finallyr?   s   &r	   test_try_except_star_finally,UnparseTestCase.test_try_except_star_finallyH  s      !89r'   c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       R# )za, *b, c = seqza, (*b, c) = seqza, *b[0], c = seqza, *(b, c) = seqNr>   r?   s   &r	   test_starred_assignment'UnparseTestCase.test_starred_assignmentK  s>      !12  !34  !45  !34r'   c                0    V P                  \        4       R # r#   )r   with_simpler?   s   &r	   test_with_simple UnparseTestCase.test_with_simpleQ  r   r'   c                0    V P                  \        4       R # r#   )r   with_asr?   s   &r	   test_with_asUnparseTestCase.test_with_asT  s      )r'   c                0    V P                  \        4       R # r#   )r   with_two_itemsr?   s   &r	   test_with_two_items#UnparseTestCase.test_with_two_itemsW  s      0r'   c                J    V P                  R 4       V P                  R4       R# )z{**{'y': 2}, 'x': 1}z{**{'y': 2}, **{'x': 1}}Nr>   r?   s   &r	   test_dict_unpacking_in_dict+UnparseTestCase.test_dict_unpacking_in_dictZ  s       !<=  !@Ar'   c                6   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R	4       V P                  R
4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )za[i]za[i,]za[i, j]za[(*a,)]za[*a]za[b, *a]za[*a, c]za[b, *a, c]	a[*a, *a]za[b, *a, *a]za[*a, b, *a]za[*a, *a, b]za[b, *a, *a, c]z	a[(a:=b)]za[(a:=b,c)]a[()]za[i:j]za[:j]za[i:]za[i:j:k]za[:j:k]za[i::k]za[i:j,]z	a[i:j, k]Nr>   r?   s   &r	   test_slicesUnparseTestCase.test_slices_  sS     (  )  +  ,  )  ,  ,  /  -  0  0  0  !23  -  /  )  *  )  )  ,  +  +  +  -r'   c           
         V P                  \        P                  ! R \        P                  ! R\        P                  ! 4       R7      R7      4       R # )NXidctx)exccause)r    r   RaiseNameLoadr?   s   &r	   test_invalid_raise"UnparseTestCase.test_invalid_raisez  s,    399SXX#((*5UVWr'   c           	         V P                  \        P                  ! \        P                  ! R \        P                  ! 4       R7      \        P
                  ! R R7      .R7      4       R# )testr   ro   )valuesN)r    r   	JoinedStrr   r   rq   r?   s   &r	   test_invalid_fstring_value*UnparseTestCase.test_invalid_fstring_value}  sA    MMHHCHHJ7LLv.	
r'   c           
         V P                  \        P                  ! \        P                  ! \        P                  ! R R7      RRR7      4      R4       R# )z\\ro   N)rp   
conversionformat_specz{'\\\\'})r*   r   r   FormattedValuerq   r?   s   &r	   test_fstring_backslash&UnparseTestCase.test_fstring_backslash  s@    ..&)ll&@+-,0 *	+r'   c                R    V P                  \        P                  ! R R7      4       R # )Nro   )r    r   	YieldFromr?   s   &r	   test_invalid_yield_from'UnparseTestCase.test_invalid_yield_from  s    3==t45r'   c                X   \         P                  ! R \         P                  ! RR7      .R7      pV P                  \         P                  ! V4      R4       \         P                  ! R \         P                  ! RR7      .RR7      pV P                  \         P                  ! V4      R4       R# )modx)name)modulenameszfrom mod import xN)r   r   level)r   
ImportFromaliasr*   r   )r   trees   & r	   test_import_from_level_none+UnparseTestCase.test_import_from_level_none  sp    ~~U399#3F2GHT*,?@~~U399#3F2GtTT*,?@r'   c                F    RpV F  pV P                  RV R24       K  	  R# )this ends with double quote"z'''N)r   z"this includes a """triple quote"""z\r	z\t
z\nz	\r	\t
\nz$""">>> content = """blabla""" <<<"""z	foo\n\x00z' \'\'\'""" ""\'\' \'u   🐍⛎𩸽üéş^\\X\\BB⟿r>   )r   
docstrings	docstrings   &  r	   test_docstringsUnparseTestCase.test_docstrings  s,    

 $I$$s9+S%9: $r'   c                ~   \         P                  pV P                  V! \         P                  ! \         P                  ! \         P
                  ! RR7      4      .4      4      R4       V P                  V! \         P                  ! \         P                  ! \         P
                  ! RR7      4      .4      4      R4       R# )   ro   z(1,)z	(1, 2, 3)N)r	  )r	  rv      )r   fix_missing_locationsr+   ModuleExprrq   )r   locss   & r	   test_constant_tuples$UnparseTestCase.test_constant_tuples  sz    ((  SXXcll&>?@ABF	L  SXXcll&CDEFG	
r'   c                >    R F  pV P                  VRR7       K  	  R# )	() -> int	func_typemodeN)r  z(int, int) -> intz=(Callable[complex], More[Complex(call.to_typevar())]) -> Noner>   )r   function_types   & r	   test_function_type"UnparseTestCase.test_function_type  s#    
M
 $$]$E
r'   c                >    R F  pV P                  VRR7       K  	  R# )a = 5 # type:Ttype_commentsN)r  za = 5 # type: intza = 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
	passzfor x in y: # type: int
	passz#async for x in y: # type: int
	passzwith x(): # type: int
	passz!async with x(): # type: int
	passr>   r   	statements   & r	   test_type_comments"UnparseTestCase.test_type_comments  s#    
I $$Yd$C
r'   c                >    R F  pV P                  VRR7       K  	  R# )a = 5 # type: ignoreTr  N)
r"  za = 5 # type: ignore and morezdef 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
	passzwith x(): # type: ignore
	passz$async with x(): # type: ignore
	passr>   r  s   & r	   test_type_ignore UnparseTestCase.test_type_ignore  s#    
I $$Yd$C
r'   c                    V P                  R RR7       V P                  RRR7       RpV F$  pV F  pV P                  V RV 2RR7       K  	  K&  	  R# )zi = 1; 'expr'; raise Exceptionsingler  z i: int = 1; j: float = 0; k += lz; N)z'expr'z(i := 1)z
import foozfrom foo import barzi = 1zi += 1z
i: int = 1zreturn ipassbreakcontinuezdel izassert izglobal iz
nonlocal jzawait izyield izyield from izraise iztype t[T] = ...ir+   )r   
combinableabs   &   r	   #test_unparse_interactive_semicolons3UnparseTestCase.test_unparse_interactive_semicolons  sd      !A Q  !C( S

. A((A3b8(D   r'   c                ~    V P                  R RRR7       V P                  RRRR7       V P                  RRRR7       R# )	z$if i:
 'expr'
else:
 raise Exceptionz*if i:
    'expr'
else:
    raise Exceptionr&  r  zP@decorator1
@decorator2
def func():
 'docstring'
 i = 1; 'expr'; raise Exceptionz`@decorator1
@decorator2
def func():
    """docstring"""
    i = 1
    'expr'
    raise ExceptionzO@decorator1
@decorator2
class cls:
 'docstring'
 i = 1; 'expr'; raise Exceptionz_@decorator1
@decorator2
class cls:
    """docstring"""
    i = 1
    'expr'
    raise ExceptionNr+  r?   s   &r	   $test_unparse_interactive_integrity_14UnparseTestCase.test_unparse_interactive_integrity_1  sZ      5; 	! 	

 	  bx 	! 	

 	  aw 	! 	
r'   c                    . R NRNRNRNRNRNRNRNRNR	NR
NRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRN F  pV P                  VR R!7       K  	  R"# )#zdef x():
    passzdef x(y):
    passzasync def x():
    passzasync def x(y):
    passzfor x in y:
    passzasync for x in y:
    passzwith x():
    passzasync with x():
    passdef f():
    passzdef f(a):
    passzdef f(b=2):
    passzdef f(a, b):
    passzdef f(a, b=2):
    passzdef f(a=5, b=2):
    passzdef f(*, a=1, b=2):
    passzdef f(*, a=1, b):
    passzdef f(*, a, b=2):
    passz(def f(a, b=None, *, c, **kwds):
    passz+def f(a=2, *args, c=5, d, **kwds):
    passz def f(*args, **kwargs):
    passz)class cls:

    def f(self):
        passz,class cls:

    def f(self, a):
        passz.class cls:

    def f(self, b=2):
        passz/class cls:

    def f(self, a, b):
        passz1class cls:

    def f(self, a, b=2):
        passz3class cls:

    def f(self, a=5, b=2):
        passz6class cls:

    def f(self, *, a=1, b=2):
        passz4class cls:

    def f(self, *, a=1, b):
        passz4class cls:

    def f(self, *, a, b=2):
        passzBclass cls:

    def f(self, a, b=None, *, c, **kwds):
        passzEclass cls:

    def f(self, a=2, *args, c=5, d, **kwds):
        passz:class cls:

    def f(self, *args, **kwargs):
        passr&  r  Nr+  r  s   & r	   $test_unparse_interactive_integrity_24UnparseTestCase.test_unparse_interactive_integrity_2  sm   !
 !
!!
 '!
 (	!

 $!
 *!
 "!
 (!
 !!
 "!
 $!
 %!
 '!
 )!
 ,!
  *!!
" *#!
$ 8%!
& ;'!
( 0)!
* ;+!
, >-!
. @/!
0 A1!
2 C3!
4 E5!
6 H7!
8 F9!
: F;!
< T=!
> W?!
@ LA!
ID $$YX$>E!
r'   c                b    R F(  pVR,           pVR,           pV P                  W#RR7       K*  	  R# )def x():z	
 i=1;j=2z
    i = 1
    j = 2r&  r  N)r9  z	def x(y):zasync def x():zasync def x(y):zfor x in y:zasync for x in y:z	with x():zasync with x():zdef f():z	def f(a):zdef f(b=2):zdef f(a, b):zdef f(a, b=2):zdef f(a=5, b=2):zdef f(*, a=1, b=2):zdef f(*, a=1, b):zdef f(*, a, b=2):zdef f(a, b=None, *, c, **kwds):z"def f(a=2, *args, c=5, d, **kwds):zdef f(*args, **kwargs):r+  )r   r  srcouts   &   r	   $test_unparse_interactive_integrity_34UnparseTestCase.test_unparse_interactive_integrity_33  s8    
I, l*C66C$$SH$=3
r'   r1   N);r2   r3   r4   r5   r@   rC   rH   rK   rN   rQ   rT   rW   r[   r_   rc   rf   rk   rs   rx   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  r  r#  r/  r2  r6  r<  r7   r8   r9   s   @r	   r<   r<      s    
*?8F7
+
0,+-61-
2(49A2.-+:4
:@2M(5:5.*1B
.6X
+6A;(
FD DE>
$#?J> >r'   r<   c                   ~   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tRtV tR# )CosmeticTestCaseiP  zATest if there are cosmetic issues caused by unnecessary additionsc                   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R	4       V P                  R
4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )z(a := b)zawait xzx if x else yzlambda x: xz1 + 1z	1 + 2 / 3z(1 + 2) / 3z(1 + 2) * 3 + 4 * (5 + 2)z(1 + 2) * 3 + 4 * (5 + 2) ** 2z~xzx and yzx and y and zzx and (y and x)z(x and y) and zz(x ** y) ** z ** qzx >> yzx << yzx >> y and x >> zzx + y - z * q ^ t ** kzP * V if P and V else n * R * Tz"lambda P, V, n: P * V == n * R * Tzflag & (other | foo)z
not x == yzx == (not y)zyield xzyield from xzcall((yield x))zreturn x + (yield x)Nr+  r?   s   &r	   test_simple_expressions_parens/CosmeticTestCase.test_simple_expressions_parensS  s     ,  +  1  /  )  -  /  !<=  !AB  &  +  1  !23  !23  !56  *  *  !45  !9:  !BC  !EF  !78  .  0  +  0  !23  !78r'   c                Z   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R	4       R
# )class X:
    passzclass X(A):
    passzclass X(A, B, C, D):
    passzclass X(x=y):
    passzclass X(metaclass=z):
    passzclass X(x=y, z=d):
    passzclass X(A, x=y):
    passzclass X(A, **kw):
    passzclass X(*args):
    passz"class X(*args, **kwargs):
    passNr+  r?   s   &r	   test_class_bases_and_keywords.CosmeticTestCase.test_class_bases_and_keywordsq  s      !56  !89  !AB  !:;  !BC  !?@  !=>  !>?  !<=  !FGr'   c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )rF   z*f'-{f'''*{f"""+{f".{f'{x}'}."}+"""}*'''}-'z/f'-{f'*{f'''+{f""".{f"{f'{x}'}"}."""}+'''}*'}-'rG   zf'{x}\n'zf"{'\n'}\n"zf"{f'{x}\n'}\n"Nr+  r?   s   &r	   r@   CosmeticTestCase.test_fstrings}  sj      !RS  !YZ  !`a  !67  -  !45  !89r'   c                `    Rp\          F!  pV F  pV P                  V V 24       K  	  K#  	  R# )"""simple doc string"""N)rJ  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+   )r   r  prefixr  s   &   r	   r   CosmeticTestCase.test_docstrings  s6    

& )F'	((F8I;)?@ ( )r'   c                    Rp\          F4  pV F+  pV V 2pV P                  V4       V P                  V4       K-  	  K6  	  R# )a = """false"""N)rO  z("""false""" + """unless its optimized"""z1 + 1
"""false"""z"f"""no, top level but f-fstring""")rK  r   r/   )r   docstrings_negativerL  negativer:  s   &    r	   test_docstrings_negative_cases/CosmeticTestCase.test_docstrings_negative_cases  sL    
 )F/  
+((---c2 0 )r'   c                z    R F  pV P                  V R24       K  	  R F  pV P                  V R24       K  	  R# )+1z 1N)rU  -~)notr+  )r   rL  s   & r	   test_unary_op_factor%CosmeticTestCase.test_unary_op_factor  s>    %F$$xq\2 &F$$xr]3 r'   c                   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R	4       V P                  R
4       V P                  R4       V P                  R4       V P                  R4       R# )r   za[1]za[1, 2]za[*a,]za[1, *a]za[*a, 2]za[1, *a, 2]r   za[1, *a, *a]za[*a, 1, *a]za[*a, *a, 1]za[1, *a, *a, 2]z
a[1:2, *a]z
a[*a, 1:2]Nr+  r?   s   &r	   r   CosmeticTestCase.test_slices  s      )  (  + 	  *  ,  ,  /  -  0  0  0  !23  .  .r'   c                   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )	zlambda: somethingzfour = lambda: 2 + 2zlambda x: x * 2zsquare = lambda n: n ** 2zlambda x, y: x + yzadd = lambda x, y: x + yz lambda x, y, /, z, q, *, u: Nonezlambda x, *y, **z: NoneNr+  r?   s   &r	   test_lambda_parameters'CosmeticTestCase.test_lambda_parameters  sz      !45  !78  !23  !<=  !56  !;<  !CD  !:;r'   c           
         R FR  w  rR FG  pV P                  WR7      ;_uu_ 4        V P                  VP                  VR7      4       RRR4       KI  	  KT  	  R#   + '       g   i     Kb  ; i)single assignment)source_typetarget)rd  N))rb  z{target} = foo)zmultiple assignmentz{target} = {target} = bar)zfor loopzfor {target} in foo:
    pass)zasync for loopz#async for {target} in foo:
    pass)r-  za,za, bza, *b, cza, (b, c), dza, (b, c, d), *eza, (b, *c, d), eza, (b, *c, (d, e), f), gz[a]z[a, b]z
[a, *b, c]z[a, [b, c], d]z[a, [b, c, d], *e]z[a, [b, *c, d], e]z[a, [b, *c, [d, e], f], g]za, [b, c], dz[a, b, (c, d), (e, f)]za, b, [*c], d, e)r   r+   format)r   rc  sourcerd  s   &   r	   test_star_expr_assign_target-CosmeticTestCase.test_star_expr_assign_target  s_    $
K( \\k\II,,V]]&]-IJ JI)$
4 JIIs   "A	A,c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )z() = []z[] = ()z'() = [a] = c, = [d] = e, f = () = g = hza = b = c = dza, b = c, d = e, f = gz[a, b] = [c, d] = [e, f] = gza, b = [c, d] = e, f = gNr+  r?   s   &r	   %test_star_expr_assign_target_multiple6CosmeticTestCase.test_star_expr_assign_target_multiple  sh      +  +  !JK  1  !9:  !?@  !;<r'   c                Z   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R	4       R
# )zf"'''{1}\"\"\"" zf"'''{1}""\"" zf'"""{1}''' zf'"""{1}""\"' zf"'''{"\n"}""\"" zf'"""{"\n"}''' zf'"""{"\n"}""\"' zf'''"""''\'{"\n"}''' zf'''"""''\'{"\n\"'"}''' z'f'''"""''\'{"""\n\"'''""" '''\n'''}''' Nr>   r?   s   &r	   test_multiquote_joined_string.CosmeticTestCase.test_multiquote_joined_string  s      !;<  !67  !45  !78  !:;  !89  !;<  !?@  !CD  !UVr'   c                   ^ RI pVP                  R4      pV P                  \        V4      ;_uu_ 4        V P	                  R4       RRR4       V P	                  R4       V P	                  R4       V P                  \        V4      ;_uu_ 4        V P	                  R4       RRR4       V P	                  R4       V P	                  R4       R#   + '       g   i     L; i  + '       g   i     LG; i)	    Nz"\ " is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\ "? A raw string is also an option.z
f"{x:\ }" z
f"{x:\n}" zf"{x:\\ }" zf"{x:\\\ }" zf"{x:\\\n}" zf"{x:\\\\ }" )reescapeassertWarnsRegexSyntaxWarningr   )r   rq  msgs   &  r	   test_backslash_in_format_spec.CosmeticTestCase.test_backslash_in_format_spec  s    ii P Q ""=#66$$%67 7  !23  !45""=#66$$%:; 7  !67  !89 76 76s   CCC	C/	c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )z	f"{x:'}" z
f"{x:\'}" zf"{x:\\'}" zf'\'{x:"}' zf'\'{x:\"}' zf'\'{x:\\"}' Nr>   r?   s   &r	   test_quote_in_format_spec*CosmeticTestCase.test_quote_in_format_spec  s[      1  !23  !45  !34  !56  !78r'   c                   V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R	4       V P                  R
4       V P                  R4       R# )ztype A = intztype A[T] = intztype A[T: int] = intztype A[T = int] = intztype A[T: int = int] = intztype A[**P] = intztype A[**P = int] = intztype A[*Ts] = intztype A[*Ts = int] = intztype A[*Ts = *int] = intz6def f[T: int = int, **P = int, *Ts = *int]():
    passz8class C[T: int = int, **P = int, *Ts = *int]():
    passNr>   r?   s   &r	   test_type_params!CosmeticTestCase.test_type_params"  s      0  !23  !78  !89  !=>  !45  !:;  !45  !:;  !;<  !Z[  !\]r'   c                    V P                  R 4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       V P                  R4       R# )zt'{a +    b}'zt'{a +    b:x}'zt'{a +    b!s}'z	t'{ {a}}'z
t'{ {a}=}'zt'{{a}}'zt''Nr>   r?   s   &r	   	test_tstrCosmeticTestCase.test_tstr0  sf      1  !23  !23  -  .  ,  'r'   r1   N)r2   r3   r4   r5   __doc__rA  rE  r@   r  rR  rZ  r   r_  rg  rj  rm  rv  ry  r|  r  r7   r8   r9   s   @r	   r?  r?  P  s]     K9<
H:A03$4/&<K<=W:"9^( (r'   r?  c                   Z   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )ManualASTCreationTestCasei:  zJTest that AST nodes created without a type_params field unparse correctly.c                    \         P                  ! R . . \         P                  ! 4       .. R7      p\         P                  ! V4       V P	                  \         P
                  ! V4      R4       R# )r   )r   baseskeywordsbodydecorator_listrD  N)r   ClassDefPassr  r*   r   r   r   s   & r	   
test_class$ManualASTCreationTestCase.test_class=  sI    ||B388:,_ab!!$'T*,@Ar'   c           
        \         P                  ! R . . \         P                  ! 4       .. \         P                  ! R4      .R7      p\         P                  ! V4       V P                  \         P                  ! V4      R4       R# )r   T)r   r  r  r  r  type_paramszclass X[T]:
    passN)r   r  r  TypeVarr  r*   r   r  s   & r	   test_class_with_type_params5ManualASTCreationTestCase.test_class_with_type_paramsB  sZ    ||B388:,_a*-++c*:);=!!$'T*,CDr'   c                   \         P                  ! R \         P                  ! . . R. . R. R7      \         P                  ! 4       .. RR7      p\         P                  ! V4       V P                  \         P                  ! V4      R4       R# )fNposonlyargsargsvararg
kwonlyargskw_defaultskwargdefaultsr   r  r  r  returnsr5  )r   FunctionDef	argumentsr  r  r*   r   r  s   & r	   test_function'ManualASTCreationTestCase.test_functionH  sj    2BtPR`bjny{|((*
 	!!$'T*,@Ar'   c                >   \         P                  ! R \         P                  ! . . R. . R. R7      \         P                  ! 4       .. R\         P                  ! R4      .R7      p\         P
                  ! V4       V P                  \         P                  ! V4      R4       R# )r  Nr  r  r   r  r  r  r  r  zdef f[T]():
    pass)r   r  r  r  r  r  r*   r   r  s   & r	   test_function_with_type_params8ManualASTCreationTestCase.test_function_with_type_paramsS  sy    2BtPR`bjny{|((*S)*
 	!!$'T*,CDr'   c                   \         P                  ! R \         P                  ! . . R. . R. R7      \         P                  ! 4       .. R\         P                  ! R\         P
                  ! R\         P                  ! 4       R7      R7      .R7      p\         P                  ! V4       V P                  \         P                  ! V4      R4       R# )	r  Nr  r  int)r   )boundr  zdef f[T: int]():
    pass)
r   r  r  r  r  r   r   r  r*   r   r  s   & r	   (test_function_with_type_params_and_boundBManualASTCreationTestCase.test_function_with_type_params_and_bound_  s    2BtPR`bjny{|((*SCHHJ0OPQ
 	!!$'T*,HIr'   c                Z   \         P                  ! R \         P                  ! 4       \         P                  ! 4       .\         P                  ! R\         P
                  ! ^R7      R7      \         P                  ! R\         P                  ! \         P
                  ! ^R7      \         P                  ! 4       R7      R7      \         P                  ! R\         P
                  ! ^R7      R7      .R7      p\         P                  ! V4       V P                  \         P                  ! V4      R4       R	# )
r  r  ro   default_valueTsrp   r   Pr   r  r  r  z+def f[T = 1, *Ts = *1, **P = 1]():
    passN)r   r  r  r  r  rq   TypeVarTupleStarredr   	ParamSpecr  r*   r   r  s   & r	   *test_function_with_type_params_and_defaultDManualASTCreationTestCase.test_function_with_type_params_and_defaultk  s    ((*Cs||!/DE  S[[s||Z[G\bebjbjbl5mncA1FG		
 	!!$'T*,Z[r'   c                   \         P                  ! R \         P                  ! . . R. . R. R7      \         P                  ! 4       .. RR7      p\         P                  ! V4       V P                  \         P                  ! V4      R4       R# )r  Nr  r  zasync def f():
    pass)r   AsyncFunctionDefr  r  r  r*   r   r  s   & r	   test_async_function-ManualASTCreationTestCase.test_async_functiony  sl    ##2BtPR`bjny{|((*
 	!!$'T*,FGr'   c                >   \         P                  ! R \         P                  ! . . R. . R. R7      \         P                  ! 4       .. R\         P                  ! R4      .R7      p\         P
                  ! V4       V P                  \         P                  ! V4      R4       R# )r  Nr  r  r  zasync def f[T]():
    pass)r   r  r  r  r  r  r*   r   r  s   & r	   $test_async_function_with_type_params>ManualASTCreationTestCase.test_async_function_with_type_params  s{    ##2BtPR`bjny{|((*S)*
 	!!$'T*,IJr'   c                Z   \         P                  ! R \         P                  ! 4       \         P                  ! 4       .\         P                  ! R\         P
                  ! ^R7      R7      \         P                  ! R\         P                  ! \         P
                  ! ^R7      \         P                  ! 4       R7      R7      \         P                  ! R\         P
                  ! ^R7      R7      .R7      p\         P                  ! V4       V P                  \         P                  ! V4      R4       R	# )
r  r  ro   r  r  r  r  r  z1async def f[T = 1, *Ts = *1, **P = 1]():
    passN)r   r  r  r  r  rq   r  r  r   r  r  r*   r   r  s   & r	   0test_async_function_with_type_params_and_defaultJManualASTCreationTestCase.test_async_function_with_type_params_and_default  s    ##((*Cs||!/DE  S[[s||Z[G\bebjbjbl5mncA1FG		
 	!!$'T*,`ar'   r1   N)r2   r3   r4   r5   r  r  r  r  r  r  r  r  r  r  r7   r8   r9   s   @r	   r  r  :  sD     TB
E	B
E
J\	H
Kb br'   r  c                      a  ] tR tRt o Rt]P                  ! ]4      P                  R,          t	]	]	R,          3t
0 R	mtRt]R 4       tR tRtV tR# )
DirectoryTestCasei  z:Test roundtrip behaviour on all files in Lib and Lib/test.z..r   Nc                0   V P                   e   V P                   # V P                   UUu. uFN  pVP                  R4       F6  pVP                  P	                  R4      '       d   K&  VP                  4       NK8  	  KP  	  ppp\        P                  P                  R4      '       g`   V Uu0 uF"  pVP                  V P                  9   g   K   VkK$  	  pp\        \        P                  ! V^
4      4      p\        W4,          4      pW0n         V# u uppi u upi )Nz*.pybadcpu)_files_to_testtest_directoriesglobr   
startswithresolver   supportis_resource_enabledrun_always_filessetrandomsamplelist)cls	directoryitemitemstests_to_run_alwayss   &    r	   files_to_testDirectoryTestCase.files_to_test  s     )%%% !11
1	!v.99''. DLLN. 1 	 
 ||//6649 #FED#'990D0D#D $(4E #F eR01E 45E #/
#Fs   7D&D*DDc           
        \         P                  ! 4       ;_uu_ 4        \         P                  ! R \        4       V P	                  4        F~  p\
        P                  P                  '       d   \        RVP                  4        24       V P                  VR7      ;_uu_ 4        \        V4      pV P                  V4       RRR4       K  	  RRR4       R#   + '       g   i     K  ; i  + '       g   i     R# ; i)ignorezTesting )r   N)warningscatch_warningssimplefilterrt  r  r   r  verboseprintabsoluter   r
   r   )r   r  rf  s   &  r	   
test_filesDirectoryTestCase.test_files  s    $$&&!!(M:**,<<'''HT]]_$567\\4\00(.F,,V4 10	 - '& 100 '&&s$   BC*#C C*C'!	C**C;	r1   >   test_ast.pytest_patma.pytest_syntax.pytest_compile.pytest_fstring.pytest_grammar.pytest_tstring.pytest_tokenize.pytest_type_alias.pytest_asdl_parser.pytest_type_params.py)r2   r3   r4   r5   r  pathlibPath__file__parentlib_dirr  r  r  classmethodr  r  r7   r8   r9   s   @r	   r  r    s\     Dll8$++d2G6!12?
 N <
5 
5r'   r  __main__) zclass foo:
    zdef foo():
    zasync def foo():
    )"r  unittesttest.supportr   r  r  r   r  r   test.support.ast_helperr   r
   rZ   r^   r   r   r   r   r   r   r   r   r   r   r   rK  TestCaser   r<   r?  r  r  r2   mainr1   r'   r	   <module>r     s           
 0
	
		  


 ., 1 1 .6m>k m>`g({ g(Tbb 1 1 bbJ55 55p zMMO r'   