HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/lib2to3/tests/__pycache__/test_parser.cpython-37.opt-1.pyc
B

 ��g0T�@s�dZddlmZddlmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlmZdd	lmZdd
lmZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd �d e�Z"Gd!d"�d"e�Z#Gd#d$�d$e�Z$Gd%d&�d&e�Z%Gd'd(�d(e�Z&Gd)d*�d*e�Z'Gd+d,�d,ej�Z(Gd-d.�d.e�Z)Gd/d0�d0e�Z*d1d2�Z+e,d3k�r�e�-�dS)4aFTest suite for 2to3's parser and grammar files.

This is the place to add tests for changes to 2to3's grammar, such as those
merging the grammars for Python 2 and 3. In addition to specific tests for
parts of the grammar we've changed, we also make sure we can parse the
test_grammar.py files from both Python 2 and Python 3.
�)�support)�driver�driver_no_print_statement�N)r)�tokenize�)�
ParseError)�python_symbolsc@seZdZdd�ZdS)�
TestDrivercCsJd}t�|�}|�|jdjdjtj�|�|jdjdjtj�dS)Nzprint 1
print 2
rr)r�parse_string�assertEqualZchildren�type�symsZ
print_stmt)�self�s�t�r�5/usr/local/lib/python3.7/lib2to3/tests/test_parser.py�
test_formfeed"s
zTestDriver.test_formfeedN)�__name__�
__module__�__qualname__rrrrrr
 sr
c@s>eZdZdd�Zdd�Ze�ejdkd�dd��Z	d	d
�Z
dS)�TestPgen2CachingcCstjtjddd�dS)NFT)�save�force)�pgen2_driver�load_grammarr�grammar_path)rrrr�test_load_grammar_from_txt_file*sz0TestPgen2Caching.test_load_grammar_from_txt_filec	Cs�t��}zptj�|tj�tj��}t�	tj|�t
�|�}t
j|ddd�|�
tj�|��t�|�t
j|ddd�Wdt�|�XdS)NT)rrF)�tempfile�mkdtemp�os�path�join�basenamerr�shutil�copyr�_generate_pickle_namer�
assertTrue�exists�unlink�rmtree)r�tmpdir�grammar_copy�pickle_namerrr�test_load_grammar_from_pickle-s

z.TestPgen2Caching.test_load_grammar_from_pickleNzsys.executable requiredc
CsDt��}tj�|d�}�zt�|�tj�tj�}tj�||�}tj�||�}t	�
tj|�t	�
tj|�t�|�}t�|�}|�
||�tj|ddd�|�tj�|��ttj�}d|d<tjtjdd|fg|d�|�tj�|��t|d	��4}	t|d	��}
|j|	��|
��d
d�WdQRXWdQRXWdt	�|�XdS)NZsubdirT)rrZrandomZPYTHONHASHSEEDz-cz{
from lib2to3.pgen2 import driver as pgen2_driver
pgen2_driver.load_grammar(%r, save=True, force=True)
                    )�env�rbzGGrammar caches generated using different hash seeds were not identical.)�msg)rr r!r"r#�mkdirr$rrr%r&rr'ZassertNotEqualrr(r)�dict�environ�
subprocessZ
check_call�sys�
executable�openr�readr+)rr,Z	tmpsubdirZgrammar_baser-Zgrammar_sub_copyr.Zpickle_sub_nameZsub_envZ
pickle_f_1Z
pickle_f_2rrr�!test_load_grammar_from_subprocess?s8



 z2TestPgen2Caching.test_load_grammar_from_subprocesscsftd�Gdd�d��G��fdd�d�}|�tj�<|�tjtj��t��d�}|�|j	d�dS)Nz
.load_testc@seZdZdd�ZdS)z=TestPgen2Caching.test_load_packaged_grammar.<locals>.MyLoadercSst�ddi�S)N�elephant�)�pickle�dumps)r�whererrr�get_datakszFTestPgen2Caching.test_load_packaged_grammar.<locals>.MyLoader.get_dataN)rrrrArrrr�MyLoaderjsrBcs eZdZdZej�����ZdS)z=TestPgen2Caching.test_load_packaged_grammar.<locals>.MyModuleZparsertestmoduleN)rrr�__file__�	importlib�util�spec_from_loader�__spec__r)rB�modnamerr�MyModulemsrIzGrammar.txtr=)
rr7�modulesZ
addCleanup�operator�delitemrZload_packaged_grammarrr<)rrI�gr)rBrHr�test_load_packaged_grammarhsz+TestPgen2Caching.test_load_packaged_grammar)rrrrr/�unittestZskipIfr7r8r;rNrrrrr)s)rc@seZdZdd�Zdd�ZdS)�GrammarTestcCst�|�dS)N)rr)r�coderrr�validatewszGrammarTest.validatecCs0y|�|�Wntk
r"Yn
Xtd��dS)Nz Syntax shouldn't have been valid)rRr�AssertionError)rrQrrr�invalid_syntaxzs
zGrammarTest.invalid_syntaxN)rrrrRrTrrrrrPvsrPc@seZdZdd�ZdS)�TestMatrixMultiplicationcCs|�d�|�d�dS)Nza @ bza @= b)rR)rrrr�#test_matrix_multiplication_operator�s
z<TestMatrixMultiplication.test_matrix_multiplication_operatorN)rrrrVrrrrrU�srUc@seZdZdd�ZdS)�
TestYieldFromcCs"|�d�|�d�|�d�dS)Nzyield from xz(yield from x) + yz
yield from)rRrT)rrrr�test_yield_from�s

zTestYieldFrom.test_yield_fromN)rrrrXrrrrrW�srWc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestAsyncAwaitcCsr|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�|�d
�|�d�dS)NzLasync def foo():
                             await x
                      zYasync def foo():
                             [i async for i in b]
                      z�async def foo():
                             {i for i in b
                                async for i in a if await i
                                  for b in i}
                      zdasync def foo():
                             [await i for i in b if await c]
                      zYasync def foo():
                             [ i for i in b if c]
                      zhasync def foo():

            def foo(): pass

            def foo(): pass

            await x
        zasync def foo(): return await azTdef foo():
            def foo(): pass
            async def foo(): await x
        zawait xz5def foo():
                                   await xzedef foo():
            def foo(): pass
            async def foo(): pass
            await x
        )rRrT)rrrr�test_await_expr�s(

zTestAsyncAwait.test_await_exprcCs"|�d�|�d�|�d�dS)Nz	async = 1z	await = 1zdef async(): pass)rR)rrrr�test_async_var�s

zTestAsyncAwait.test_async_varcCs|�d�|�d�dS)NzDasync def foo():
                             async for a in b: passzDdef foo():
                                   async for a in b: pass)rRrT)rrrr�test_async_with�szTestAsyncAwait.test_async_withcCs|�d�|�d�dS)Nz@async def foo():
                             async with a: passz@def foo():
                                   async with a: pass)rRrT)rrrr�test_async_for�szTestAsyncAwait.test_async_forN)rrrrZr[r\r]rrrrrY�s1rYc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestRaiseChangescCs|�d�dS)N�raise)rR)rrrr�test_2x_style_1�sz TestRaiseChanges.test_2x_style_1cCs|�d�dS)Nz
raise E, V)rR)rrrr�test_2x_style_2�sz TestRaiseChanges.test_2x_style_2cCs|�d�dS)Nz
raise E, V, T)rR)rrrr�test_2x_style_3�sz TestRaiseChanges.test_2x_style_3cCs|�d�dS)Nzraise E, V, T, Z)rT)rrrr�test_2x_style_invalid_1�sz(TestRaiseChanges.test_2x_style_invalid_1cCs|�d�dS)Nzraise E1 from E2)rR)rrrr�
test_3x_style�szTestRaiseChanges.test_3x_stylecCs|�d�dS)Nzraise E, V from E1)rT)rrrr�test_3x_style_invalid_1�sz(TestRaiseChanges.test_3x_style_invalid_1cCs|�d�dS)Nzraise E from E1, E2)rT)rrrr�test_3x_style_invalid_2�sz(TestRaiseChanges.test_3x_style_invalid_2cCs|�d�dS)Nzraise from E1, E2)rT)rrrr�test_3x_style_invalid_3�sz(TestRaiseChanges.test_3x_style_invalid_3cCs|�d�dS)Nzraise E from)rT)rrrr�test_3x_style_invalid_4�sz(TestRaiseChanges.test_3x_style_invalid_4N)rrrr`rarbrcrdrerfrgrhrrrrr^�sr^c@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=S)>�TestUnpackingGeneralizationscCs|�d�dS)Nzfunc(1, *(2, 3), 4))rR)rrrr�test_mid_positional_star�sz5TestUnpackingGeneralizations.test_mid_positional_starcCs|�d�dS)Nz,func(**{'eggs':'scrambled', 'spam':'fried'}))rR)rrrr�test_double_star_dict_literal�sz:TestUnpackingGeneralizations.test_double_star_dict_literalcCs|�d�dS)Nz*func(spam='fried', **{'eggs':'scrambled'}))rR)rrrr�,test_double_star_dict_literal_after_keywords�szITestUnpackingGeneralizations.test_double_star_dict_literal_after_keywordscCs|�d�|�d�dS)Nzfunc(**{'a':2} or {})zfunc(**() or {}))rR)rrrr�test_double_star_expressions
z8TestUnpackingGeneralizations.test_double_star_expressioncCs|�d�dS)Nzfunc(*[] or [2]))rR)rrrr�test_star_expressionsz1TestUnpackingGeneralizations.test_star_expressioncCs|�d�dS)Nz[*{2}, 3, *[4]])rR)rrrr�test_list_displaysz.TestUnpackingGeneralizations.test_list_displaycCs|�d�dS)Nz{*{2}, 3, *[4]})rR)rrrr�test_set_display
sz-TestUnpackingGeneralizations.test_set_displaycCs|�d�dS)Nz{**{}})rR)rrrr�test_dict_display_1
sz0TestUnpackingGeneralizations.test_dict_display_1cCs|�d�dS)Nz{**{}, 3:4, **{5:6, 7:8}})rR)rrrr�test_dict_display_2sz0TestUnpackingGeneralizations.test_dict_display_2cCs|�d�dS)Nzf(a, *b, *c, d))rR)rrrr�test_argument_unpacking_1sz6TestUnpackingGeneralizations.test_argument_unpacking_1cCs|�d�dS)Nzf(**a, **b))rR)rrrr�test_argument_unpacking_2sz6TestUnpackingGeneralizations.test_argument_unpacking_2cCs|�d�dS)Nzf(2, *a, *b, **b, **c, **d))rR)rrrr�test_argument_unpacking_3sz6TestUnpackingGeneralizations.test_argument_unpacking_3cCs|�d�|�d�dS)Nzdef f(a, b): call(a, b)zdef f(a, b,): call(a, b,))rR)rrrr�test_trailing_commas_1s
z3TestUnpackingGeneralizations.test_trailing_commas_1cCs|�d�|�d�dS)Nzdef f(a, *b): call(a, *b)zdef f(a, *b,): call(a, *b,))rR)rrrr�test_trailing_commas_2 s
z3TestUnpackingGeneralizations.test_trailing_commas_2cCs|�d�|�d�dS)Nzdef f(a, b=1): call(a, b=1)zdef f(a, b=1,): call(a, b=1,))rR)rrrr�test_trailing_commas_3$s
z3TestUnpackingGeneralizations.test_trailing_commas_3cCs|�d�|�d�dS)Nzdef f(a, **b): call(a, **b)zdef f(a, **b,): call(a, **b,))rR)rrrr�test_trailing_commas_4(s
z3TestUnpackingGeneralizations.test_trailing_commas_4cCs|�d�|�d�dS)Nzdef f(*a, b=1): call(*a, b=1)zdef f(*a, b=1,): call(*a, b=1,))rR)rrrr�test_trailing_commas_5,s
z3TestUnpackingGeneralizations.test_trailing_commas_5cCs|�d�|�d�dS)Nzdef f(*a, **b): call(*a, **b)zdef f(*a, **b,): call(*a, **b,))rR)rrrr�test_trailing_commas_60s
z3TestUnpackingGeneralizations.test_trailing_commas_6cCs|�d�|�d�dS)Nzdef f(*, b=1): call(*b)zdef f(*, b=1,): call(*b,))rR)rrrr�test_trailing_commas_74s
z3TestUnpackingGeneralizations.test_trailing_commas_7cCs|�d�|�d�dS)Nzdef f(a=1, b=2): call(a=1, b=2)z!def f(a=1, b=2,): call(a=1, b=2,))rR)rrrr�test_trailing_commas_88s
z3TestUnpackingGeneralizations.test_trailing_commas_8cCs|�d�|�d�dS)Nzdef f(a=1, **b): call(a=1, **b)z!def f(a=1, **b,): call(a=1, **b,))rR)rrrr�test_trailing_commas_9<s
z3TestUnpackingGeneralizations.test_trailing_commas_9cCs|�d�|�d�dS)Nzf = lambda a, b: call(a, b)zf = lambda a, b,: call(a, b,))rR)rrrr�test_trailing_commas_lambda_1@s
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_1cCs|�d�|�d�dS)Nzf = lambda a, *b: call(a, *b)zf = lambda a, *b,: call(a, *b,))rR)rrrr�test_trailing_commas_lambda_2Ds
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_2cCs|�d�|�d�dS)Nzf = lambda a, b=1: call(a, b=1)z!f = lambda a, b=1,: call(a, b=1,))rR)rrrr�test_trailing_commas_lambda_3Hs
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_3cCs|�d�|�d�dS)Nzf = lambda a, **b: call(a, **b)z!f = lambda a, **b,: call(a, **b,))rR)rrrr�test_trailing_commas_lambda_4Ls
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_4cCs|�d�|�d�dS)Nz!f = lambda *a, b=1: call(*a, b=1)z#f = lambda *a, b=1,: call(*a, b=1,))rR)rrrr�test_trailing_commas_lambda_5Ps
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_5cCs|�d�|�d�dS)Nz!f = lambda *a, **b: call(*a, **b)z#f = lambda *a, **b,: call(*a, **b,))rR)rrrr�test_trailing_commas_lambda_6Ts
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_6cCs|�d�|�d�dS)Nzf = lambda *, b=1: call(*b)zf = lambda *, b=1,: call(*b,))rR)rrrr�test_trailing_commas_lambda_7Xs
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_7cCs|�d�|�d�dS)Nz#f = lambda a=1, b=2: call(a=1, b=2)z%f = lambda a=1, b=2,: call(a=1, b=2,))rR)rrrr�test_trailing_commas_lambda_8\s
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_8cCs|�d�|�d�dS)Nz#f = lambda a=1, **b: call(a=1, **b)z%f = lambda a=1, **b,: call(a=1, **b,))rR)rrrr�test_trailing_commas_lambda_9`s
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_9N)!rrrrjrkrlrmrnrorprqrrrsrtrurvrwrxryrzr{r|r}r~rr�r�r�r�r�r�r�r�rrrrri�s<ric@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+S),�TestFunctionAnnotationscCs|�d�dS)Nzdef f(x) -> list: pass)rR)rrrr�test_1gszTestFunctionAnnotations.test_1cCs|�d�dS)Nzdef f(x:int): pass)rR)rrrr�test_2jszTestFunctionAnnotations.test_2cCs|�d�dS)Nzdef f(*x:str): pass)rR)rrrr�test_3mszTestFunctionAnnotations.test_3cCs|�d�dS)Nzdef f(**x:float): pass)rR)rrrr�test_4pszTestFunctionAnnotations.test_4cCs|�d�dS)Nzdef f(x, y:1+2): pass)rR)rrrr�test_5sszTestFunctionAnnotations.test_5cCs|�d�dS)Nzdef f(a, (b:1, c:2, d)): pass)rR)rrrr�test_6vszTestFunctionAnnotations.test_6cCs|�d�dS)Nz/def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6): pass)rR)rrrr�test_7yszTestFunctionAnnotations.test_7cCsd}|�|�dS)Nzgdef f(a, (b:1, c:2, d), e:3=4, f=5,
                        *g:6, h:7, i=8, j:9=10, **k:11) -> 12: pass)rR)rrrrr�test_8|szTestFunctionAnnotations.test_8cCsd}|�|�dS)Nz�def f(
          a: str,
          b: int,
          *,
          c: bool = False,
          **kwargs,
        ) -> None:
            call(c=c, **kwargs,))rR)rrrrr�test_9�szTestFunctionAnnotations.test_9cCsd}|�|�dS)Nz@def f(
          a: str,
        ) -> None:
            call(a,))rR)rrrrr�test_10�szTestFunctionAnnotations.test_10cCsd}|�|�dS)NzGdef f(
          a: str = '',
        ) -> None:
            call(a=a,))rR)rrrrr�test_11�szTestFunctionAnnotations.test_11cCsd}|�|�dS)NzHdef f(
          *args: str,
        ) -> None:
            call(*args,))rR)rrrrr�test_12�szTestFunctionAnnotations.test_12cCs|�d�|�d�dS)Nz)def f(a: str, b: int) -> None: call(a, b)z+def f(a: str, b: int,) -> None: call(a, b,))rR)rrrr�test_13�s
zTestFunctionAnnotations.test_13cCs|�d�|�d�dS)Nz+def f(a: str, *b: int) -> None: call(a, *b)z-def f(a: str, *b: int,) -> None: call(a, *b,))rR)rrrr�test_14�s
zTestFunctionAnnotations.test_14cCs|�d�|�d�dS)Nz-def f(a: str, b: int=1) -> None: call(a, b=1)z/def f(a: str, b: int=1,) -> None: call(a, b=1,))rR)rrrr�test_15�s
zTestFunctionAnnotations.test_15cCs|�d�|�d�dS)Nz-def f(a: str, **b: int) -> None: call(a, **b)z/def f(a: str, **b: int,) -> None: call(a, **b,))rR)rrrr�test_16�s
zTestFunctionAnnotations.test_16cCs|�d�|�d�dS)Nz/def f(*a: str, b: int=1) -> None: call(*a, b=1)z1def f(*a: str, b: int=1,) -> None: call(*a, b=1,))rR)rrrr�test_17�s
zTestFunctionAnnotations.test_17cCs|�d�|�d�dS)Nz/def f(*a: str, **b: int) -> None: call(*a, **b)z1def f(*a: str, **b: int,) -> None: call(*a, **b,))rR)rrrr�test_18�s
zTestFunctionAnnotations.test_18cCs|�d�|�d�dS)Nz$def f(*, b: int=1) -> None: call(*b)z&def f(*, b: int=1,) -> None: call(*b,))rR)rrrr�test_19�s
zTestFunctionAnnotations.test_19cCs|�d�|�d�dS)Nz2def f(a: str='', b: int=2) -> None: call(a=a, b=2)z4def f(a: str='', b: int=2,) -> None: call(a=a, b=2,))rR)rrrr�test_20�s
zTestFunctionAnnotations.test_20cCs|�d�|�d�dS)Nz2def f(a: str='', **b: int) -> None: call(a=a, **b)z4def f(a: str='', **b: int,) -> None: call(a=a, **b,))rR)rrrr�test_21�s
zTestFunctionAnnotations.test_21N)rrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�fs*r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestVarAnnotationscCs|�d�dS)Nz
var1: int = 5)rR)rrrrr��szTestVarAnnotations.test_1cCs|�d�dS)Nzvar2: [int, str])rR)rrrrr��szTestVarAnnotations.test_2cCs|�d�dS)NzCdef f():
    st: str = 'Hello'
    a.b: int = (1, 2)
    return st
)rR)rrrrr��szTestVarAnnotations.test_3cCs|�d�dS)Nz$def fbad():
    x: int
    print(x)
)rR)rrrrr��szTestVarAnnotations.test_4cCs|�d�dS)Nzeclass C:
    x: int
    s: str = 'attr'
    z = 2
    def __init__(self, x):
        self.x: int = x
)rR)rrrrr��szTestVarAnnotations.test_5cCs|�d�dS)Nzlst: List[int] = [])rR)rrrrr��szTestVarAnnotations.test_6N)	rrrr�r�r�r�r�r�rrrrr��sr�c@seZdZdd�Zdd�ZdS)�
TestExceptcCsd}|�|�dS)NzP
            try:
                x
            except E as N:
                y)rR)rrrrr�test_new�szTestExcept.test_newcCsd}|�|�dS)NzN
            try:
                x
            except E, N:
                y)rR)rrrrr�test_old�szTestExcept.test_oldN)rrrr�r�rrrrr��sr�c@seZdZdZdd�ZdS)�TestStringLiterals)*�'�"zr'zr"zR'zR"zu'zu"zU'zU"zb'zb"zB'zB"zf'zf"zF'zF"zur'zur"zUr'zUr"zuR'zuR"zUR'zUR"zbr'zbr"zBr'zBr"zbR'zbR"zBR'zBR"zrb'zrb"zRb'zRb"zrB'zrB"zRB'zRB"cCsLxF|jD]<}dj||dd�}|�|�dj||dd�}|�|�qWdS)Nz{p}spamspamspam{s}���)�prz{p}{s}{s}eggs{s}{s}{s})�prefixes�formatrR)rZpreZsingleZtriplerrr�test_lits

zTestStringLiterals.test_litN)rrrr�r�rrrrr��sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestSetLiteralcCs|�d�dS)Nzx = {'one'})rR)rrrrr�szTestSetLiteral.test_1cCs|�d�dS)Nzx = {'one', 1,})rR)rrrrr�szTestSetLiteral.test_2cCs|�d�dS)Nzx = {'one', 'two', 'three'})rR)rrrrr�szTestSetLiteral.test_3cCs|�d�dS)Nzx = {2, 3, 4,})rR)rrrrr�szTestSetLiteral.test_4N)rrrr�r�r�r�rrrrr�
sr�c@seZdZdd�ZdS)�
TestIdentfiercCs,|�d�|�d�|�d�|�d�dS)Nu!Örter = 'places'
grün = 'green'u蟒 = a蟒 = 锦蛇 = 1uµ = aµ = µµ = 1uA𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = a_𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 1)rR)rrrr�test_non_ascii_identifierss


z(TestIdentfier.test_non_ascii_identifiersN)rrrr�rrrrr�sr�c@seZdZdd�Zdd�ZdS)�TestNumericLiteralscCs|�d�|�d�dS)NZ0o7777777777777Z0o7324528887)rRrT)rrrr�test_new_octal_notation&s
z+TestNumericLiterals.test_new_octal_notationcCs|�d�|�d�dS)NZ0b101010Z	0b0101021)rRrT)rrrr�test_new_binary_notation*s
z,TestNumericLiterals.test_new_binary_notationN)rrrr�r�rrrrr�%sr�c@seZdZdd�ZdS)�TestClassDefcCs6|�d�|�d�|�d�|�d�|�d�dS)Nzclass B(t=7): passzclass B(t, *args): passzclass B(t, **kwargs): passz!class B(t, *args, **kwargs): passz'class B(t, y=9, *args, **kwargs,): pass)rR)rrrr�test_new_syntax0s




zTestClassDef.test_new_syntaxN)rrrr�rrrrr�/sr�c@s eZdZdZdd�Zdd�ZdS)�TestParserIdempotencyz,A cut-down version of pytree_idempotency.py.cCsx�t��D]�}t|d��}t�|j�d}WdQRX|�|d|�t|d|d��}|��}WdQRXyt�	|�}WnXt
k
r�yt�	|�}Wn4t
k
r�}z|�d||f�Wdd}~XYnXYnXt
|�}||kr
tt|||��|�d|�q
WdS)Nr1rzcan't detect encoding for %s�r)�encodingzParseError on file %s (%s)zIdempotency failed: %s)rZall_project_filesr9r�detect_encoding�readlineZassertIsNotNoner:rrrrZfail�str�print�
diff_texts)r�filepath�fpr��sourceZtree�err�newrrr�test_all_project_files<s$
*z,TestParserIdempotency.test_all_project_filescCs,t�d�t�d�t�d�t�d�dS)Nz
a, *b, c = x
z[*a, b] = x
z(z, *y, w) = m
zfor *z, m in d: pass
)rr)rrrr�test_extended_unpackingPs


z-TestParserIdempotency.test_extended_unpackingN)rrr�__doc__r�r�rrrrr�8sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestLiteralscCst�t�|�d�dS)Nz

)rrr�dedent)rrrrrrRYszTestLiterals.validatecCsd}|�|�dS)Nu�
            md5test(b"ª" * 80,
                    (b"Test Using Larger Than Block-Size Key "
                     b"and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            )rR)rrrrr�test_multiline_bytes_literals\sz*TestLiterals.test_multiline_bytes_literalscCsd}|�|�dS)Nz�
            b"""
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN">
            """
            )rR)rrrrr�'test_multiline_bytes_tripquote_literalsesz4TestLiterals.test_multiline_bytes_tripquote_literalscCsd}|�|�dS)Nu�
            md5test("ª" * 80,
                    ("Test Using Larger Than Block-Size Key "
                     "and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            )rR)rrrrr�test_multiline_str_literalsnsz(TestLiterals.test_multiline_str_literalsN)rrrrRr�r�r�rrrrr�Ws		r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestNamedAssignmentscCst�d�dS)Nzif f := x(): pass
)rr)rrrr�test_named_assignment_ifzsz-TestNamedAssignments.test_named_assignment_ifcCst�d�dS)Nzwhile f := x(): pass
)rr)rrrr�test_named_assignment_while}sz0TestNamedAssignments.test_named_assignment_whilecCst�d�dS)Nz0any((lastNum := num) == 1 for num in [1, 2, 3])
)rr)rrrr�test_named_assignment_generator�sz4TestNamedAssignments.test_named_assignment_generatorcCst�d�dS)Nz-[(lastNum := num) == 1 for num in [1, 2, 3]]
)rr)rrrr�test_named_assignment_listcomp�sz3TestNamedAssignments.test_named_assignment_listcompN)rrrr�r�r�r�rrrrr�xsr�c	Cs(|��}|��}tj||||dddd�S)Nz
(original)z(reserialized)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filenamerrrr��s
r��__main__).r�r�rrrr�rDrKr!r>r%r6r7rrOZ
lib2to3.pgen2rrZpgen2.parserZlib2to3.pygramr	rZTestCaser
rrPrUrWrYr^rir�r�r�r�r�r�r�r�r�r�r�r�r�mainrrrr�<module>sL	M
F pa
	!