python (3.12.0)
Αe*k 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)tokenizeopenread)filenamestreams E/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_unparse.pyread_pyfiler s0
x F{{} s 09zQdef 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 ZefdZddZddZddZy)ASTTestCasec | j || 5 t j |fi |}t j | }t j |fi |}| j || d d d y # 1 sw Y y xY w)N)code1ast_parse_kwargs)subTestastparseunparseassertASTEqual)selfr kwargsast1code2ast2s r
check_ast_roundtripzASTTestCase.check_ast_roundtrip sk
\\\
? ,99U-f-DKK%E99U-f-Dd+ , , ,s AA11A: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\
$ 9fckk48 9 9 9s ">ANc f |xs |}t j t j | }||fS N)r r r r r r s r
get_sourcezASTTestCase.get_source s, CIIe,-e| c | j || \ }}| j || 5 | j || d d d y # 1 sw Y y xY wN)r r )r% r assertEqualr$ s r
check_src_roundtripzASTTestCase.check_src_roundtrip sK ue4u
\\U\
3 +UE* + + + AAc | 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 ue4u
\\U\
3 .u- . . .r+ r# ) __name__
__module____qualname__r
ValueErrorr! r% r* r. r&