Your IP : 216.73.216.213


Current Path : /opt/alt/python310/lib64/python3.10/lib2to3/tests/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/lib2to3/tests/__pycache__/test_parser.cpython-310.opt-1.pyc

o

0�ig\�@s$dZddlmZddlmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZdd	lmZdd
lmZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�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,Gd1d2�d2e�Z-Gd3d4�d4ej�Z.d5d6�Z/e0d7k�re�1�dSdS)8aFTest 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@�eZdZdd�ZdS)�
TestDrivercCsJd}t�|�}|�|jdjdjtj�|�|jdjdjtj�dS)Nzprint 1
print 2
rr)r�parse_string�assertEqual�children�type�symsZ
print_stmt)�self�s�t�r�@/opt/alt/python310/lib64/python3.10/lib2to3/tests/test_parser.py�
test_formfeed#s
 zTestDriver.test_formfeedN)�__name__�
__module__�__qualname__rrrrrr!src@s>eZdZdd�Zdd�Ze�ejdud�dd��Z	d	d
�Z
dS)�TestPgen2CachingcCstjtjddd�dS)NFT�ZsaveZforce)�pgen2_driver�load_grammarr�grammar_path�rrrr�test_load_grammar_from_txt_file+sz0TestPgen2Caching.test_load_grammar_from_txt_filec	Cs�t��}z>tj�|tj�tj��}t�	tj|�t
�|�}t
j|ddd�|�
tj�|��t�|�t
j|ddd�Wt�|�dSt�|�w)NTrF)�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	Cs�t��}tj�|d�}z�t�|�tj�tj�}tj�||�}tj�||�}t	�
tj|�t	�
tj|�t�|�}t�|�}|�
||�tj|ddd�|�tj�|��ttj�}d|d<d|f}	d}
tjd|
�d	�d
|	g}tj||d�|�tj�|��t|d��)}t|d��}
|j|��|
��d
d�Wd�n1s�wYWd�n1s�wYWt	�|�dSWt	�|�dSt	�|�w)NZsubdirTrZrandomZPYTHONHASHSEEDzs
from lib2to3.pgen2 import driver as pgen2_driver
pgen2_driver.load_grammar(%r, save=True, force=True)
            zGlib2to3 package is deprecated and may not be able to parse Python 3.10+z	-Wignore:z:PendingDeprecationWarningz-c)�env�rbzGGrammar caches generated using different hash seeds were not identical.)�msg)r!r"r#r$r%�mkdirr&rrr'r(rr)ZassertNotEqualrr*r+�dict�environ�sys�
executable�
subprocessZ
check_call�openr
�readr-)rr.Z	tmpsubdirZgrammar_baser/Zgrammar_sub_copyr0Zpickle_sub_nameZsub_env�coder4�cmdZ
pickle_f_1Z
pickle_f_2rrr�!test_load_grammar_from_subprocess@sT

�
�
������z2TestPgen2Caching.test_load_grammar_from_subprocesscsftd�Gdd�d��G��fdd�d�}|�tj�<|�tjtj��t��d�}|�|j	d�dS)Nz
.load_testc@r
)z=TestPgen2Caching.test_load_packaged_grammar.<locals>.MyLoadercSst�ddi�S)N�elephant�)�pickle�dumps)r�whererrr�get_datap�zFTestPgen2Caching.test_load_packaged_grammar.<locals>.MyLoader.get_dataN)rrrrErrrr�MyLoadero�rGcs eZdZdZej�����ZdS)z=TestPgen2Caching.test_load_packaged_grammar.<locals>.MyModuleZparsertestmoduleN)rrr�__file__�	importlib�util�spec_from_loader�__spec__r�rG�modnamerr�MyModulersrPzGrammar.txtrA)
rr8�modulesZ
addCleanup�operator�delitemrZload_packaged_grammarr
r@)rrP�grrNr�test_load_packaged_grammarmsz+TestPgen2Caching.test_load_packaged_grammar)rrrr r1�unittestZskipIfr8r9r?rUrrrrr*s
,rc@�eZdZdd�Zdd�ZdS)�GrammarTestcCst�|�dS)N)rr�rr=rrr�validate|rFzGrammarTest.validatecCs*z
|�|�Wtd��tyYdSw)Nz Syntax shouldn't have been valid)rZr�AssertionErrorrYrrr�invalid_syntaxs��zGrammarTest.invalid_syntaxN)rrrrZr\rrrrrX{srXc@r
)�TestMatrixMultiplicationcC�|�d�|�d�dS)Nza @ bza @= b�rZrrrr�#test_matrix_multiplication_operator��
z<TestMatrixMultiplication.test_matrix_multiplication_operatorN)rrrr`rrrrr]�rHr]c@r
)�
TestYieldFromcCs"|�d�|�d�|�d�dS)Nzyield from xz(yield from x) + yz
yield from�rZr\rrrr�test_yield_from��

zTestYieldFrom.test_yield_fromN)rrrrdrrrrrb�rHrbc@�4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�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
        rcrrrr�test_await_expr�s






	


zTestAsyncAwait.test_await_exprcCs"|�d�|�d�|�d�dS)Nz	async = 1z	await = 1zdef async(): passr_rrrr�test_async_var�rezTestAsyncAwait.test_async_varcC�|�d�dS)NzDasync def foo():
                             async for a in b: passr_rrrr�test_async_for�rFzTestAsyncAwait.test_async_forcC�|�d�|�d�dS)Nz@async def foo():
                             async with a: passz@def foo():
                                   async with a: passrcrrrr�test_async_with�s
zTestAsyncAwait.test_async_withcCr^)NzLasync def foo():
                   return (i * 2 async for i in arange(42))zFdef foo():
                   return (i * 2 async for i in arange(42))r_rrrr�test_async_generator�s��z#TestAsyncAwait.test_async_generatorN)rrrrhrirkrmrnrrrrrg�s1rgc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestRaiseChangescCrj)N�raiser_rrrr�test_2x_style_1�rFz TestRaiseChanges.test_2x_style_1cCrj)Nz
raise E, Vr_rrrr�test_2x_style_2�rFz TestRaiseChanges.test_2x_style_2cCrj)Nz
raise E, V, Tr_rrrr�test_2x_style_3�rFz TestRaiseChanges.test_2x_style_3cCrj)Nzraise E, V, T, Z�r\rrrr�test_2x_style_invalid_1�rFz(TestRaiseChanges.test_2x_style_invalid_1cCrj)Nzraise E1 from E2r_rrrr�
test_3x_style�rFzTestRaiseChanges.test_3x_stylecCrj)Nzraise E, V from E1rtrrrr�test_3x_style_invalid_1�rFz(TestRaiseChanges.test_3x_style_invalid_1cCrj)Nzraise E from E1, E2rtrrrr�test_3x_style_invalid_2�rFz(TestRaiseChanges.test_3x_style_invalid_2cCrj)Nzraise from E1, E2rtrrrr�test_3x_style_invalid_3�rFz(TestRaiseChanges.test_3x_style_invalid_3cCrj)Nzraise E fromrtrrrr�test_3x_style_invalid_4�rFz(TestRaiseChanges.test_3x_style_invalid_4N)rrrrqrrrsrurvrwrxryrzrrrrro�sroc@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�TestUnpackingGeneralizationscCrj)Nzfunc(1, *(2, 3), 4)r_rrrr�test_mid_positional_starrFz5TestUnpackingGeneralizations.test_mid_positional_starcCrj)Nz,func(**{'eggs':'scrambled', 'spam':'fried'})r_rrrr�test_double_star_dict_literalrFz:TestUnpackingGeneralizations.test_double_star_dict_literalcCrj)Nz*func(spam='fried', **{'eggs':'scrambled'})r_rrrr�,test_double_star_dict_literal_after_keywords	rFzITestUnpackingGeneralizations.test_double_star_dict_literal_after_keywordscCr^)Nzfunc(**{'a':2} or {})zfunc(**() or {})r_rrrr�test_double_star_expressionraz8TestUnpackingGeneralizations.test_double_star_expressioncCrj)Nzfunc(*[] or [2])r_rrrr�test_star_expressionrFz1TestUnpackingGeneralizations.test_star_expressioncCrj)Nz[*{2}, 3, *[4]]r_rrrr�test_list_displayrFz.TestUnpackingGeneralizations.test_list_displaycCrj)Nz{*{2}, 3, *[4]}r_rrrr�test_set_displayrFz-TestUnpackingGeneralizations.test_set_displaycCrj)Nz{**{}}r_rrrr�test_dict_display_1rFz0TestUnpackingGeneralizations.test_dict_display_1cCrj)Nz{**{}, 3:4, **{5:6, 7:8}}r_rrrr�test_dict_display_2rFz0TestUnpackingGeneralizations.test_dict_display_2cCrj)Nzfunc(* [] or [1])r_rrrr�test_complex_star_expressionrFz9TestUnpackingGeneralizations.test_complex_star_expressioncCrj)Nz5func(**{1: 3} if False else {x: x for x in range(3)})r_rrrr�#test_complex_double_star_expression"rFz@TestUnpackingGeneralizations.test_complex_double_star_expressioncCrj)Nzf(a, *b, *c, d)r_rrrr�test_argument_unpacking_1%rFz6TestUnpackingGeneralizations.test_argument_unpacking_1cCrj)Nzf(**a, **b)r_rrrr�test_argument_unpacking_2(rFz6TestUnpackingGeneralizations.test_argument_unpacking_2cCrj)Nzf(2, *a, *b, **b, **c, **d)r_rrrr�test_argument_unpacking_3+rFz6TestUnpackingGeneralizations.test_argument_unpacking_3cCr^)Nzdef f(a, b): call(a, b)zdef f(a, b,): call(a, b,)r_rrrr�test_trailing_commas_1.raz3TestUnpackingGeneralizations.test_trailing_commas_1cCr^)Nzdef f(a, *b): call(a, *b)zdef f(a, *b,): call(a, *b,)r_rrrr�test_trailing_commas_22raz3TestUnpackingGeneralizations.test_trailing_commas_2cCr^)Nzdef f(a, b=1): call(a, b=1)zdef f(a, b=1,): call(a, b=1,)r_rrrr�test_trailing_commas_36raz3TestUnpackingGeneralizations.test_trailing_commas_3cCr^)Nzdef f(a, **b): call(a, **b)zdef f(a, **b,): call(a, **b,)r_rrrr�test_trailing_commas_4:raz3TestUnpackingGeneralizations.test_trailing_commas_4cCr^)Nzdef f(*a, b=1): call(*a, b=1)zdef f(*a, b=1,): call(*a, b=1,)r_rrrr�test_trailing_commas_5>raz3TestUnpackingGeneralizations.test_trailing_commas_5cCr^)Nzdef f(*a, **b): call(*a, **b)zdef f(*a, **b,): call(*a, **b,)r_rrrr�test_trailing_commas_6Braz3TestUnpackingGeneralizations.test_trailing_commas_6cCr^)Nzdef f(*, b=1): call(*b)zdef f(*, b=1,): call(*b,)r_rrrr�test_trailing_commas_7Fraz3TestUnpackingGeneralizations.test_trailing_commas_7cCr^)Nzdef f(a=1, b=2): call(a=1, b=2)z!def f(a=1, b=2,): call(a=1, b=2,)r_rrrr�test_trailing_commas_8Jraz3TestUnpackingGeneralizations.test_trailing_commas_8cCr^)Nzdef f(a=1, **b): call(a=1, **b)z!def f(a=1, **b,): call(a=1, **b,)r_rrrr�test_trailing_commas_9Nraz3TestUnpackingGeneralizations.test_trailing_commas_9cCr^)Nzf = lambda a, b: call(a, b)zf = lambda a, b,: call(a, b,)r_rrrr�test_trailing_commas_lambda_1Rraz:TestUnpackingGeneralizations.test_trailing_commas_lambda_1cCr^)Nzf = lambda a, *b: call(a, *b)zf = lambda a, *b,: call(a, *b,)r_rrrr�test_trailing_commas_lambda_2Vraz:TestUnpackingGeneralizations.test_trailing_commas_lambda_2cCr^)Nzf = lambda a, b=1: call(a, b=1)z!f = lambda a, b=1,: call(a, b=1,)r_rrrr�test_trailing_commas_lambda_3Zraz:TestUnpackingGeneralizations.test_trailing_commas_lambda_3cCr^)Nzf = lambda a, **b: call(a, **b)z!f = lambda a, **b,: call(a, **b,)r_rrrr�test_trailing_commas_lambda_4^raz:TestUnpackingGeneralizations.test_trailing_commas_lambda_4cCr^)Nz!f = lambda *a, b=1: call(*a, b=1)z#f = lambda *a, b=1,: call(*a, b=1,)r_rrrr�test_trailing_commas_lambda_5braz:TestUnpackingGeneralizations.test_trailing_commas_lambda_5cCr^)Nz!f = lambda *a, **b: call(*a, **b)z#f = lambda *a, **b,: call(*a, **b,)r_rrrr�test_trailing_commas_lambda_6fraz:TestUnpackingGeneralizations.test_trailing_commas_lambda_6cCr^)Nzf = lambda *, b=1: call(*b)zf = lambda *, b=1,: call(*b,)r_rrrr�test_trailing_commas_lambda_7jraz:TestUnpackingGeneralizations.test_trailing_commas_lambda_7cCr^)Nz#f = lambda a=1, b=2: call(a=1, b=2)z%f = lambda a=1, b=2,: call(a=1, b=2,)r_rrrr�test_trailing_commas_lambda_8nraz:TestUnpackingGeneralizations.test_trailing_commas_lambda_8cCr^)Nz#f = lambda a=1, **b: call(a=1, **b)z%f = lambda a=1, **b,: call(a=1, **b,)r_rrrr�test_trailing_commas_lambda_9rraz:TestUnpackingGeneralizations.test_trailing_commas_lambda_9N)#rrrr|r}r~rr�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�rrrrr{sBr{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+S),�TestFunctionAnnotationscCrj)Nzdef f(x) -> list: passr_rrrr�test_1yrFzTestFunctionAnnotations.test_1cCrj)Nzdef f(x:int): passr_rrrr�test_2|rFzTestFunctionAnnotations.test_2cCrj)Nzdef f(*x:str): passr_rrrr�test_3rFzTestFunctionAnnotations.test_3cCrj)Nzdef f(**x:float): passr_rrrr�test_4�rFzTestFunctionAnnotations.test_4cCrj)Nzdef f(x, y:1+2): passr_rrrr�test_5�rFzTestFunctionAnnotations.test_5cCrj)Nzdef f(a, (b:1, c:2, d)): passr_rrrr�test_6�rFzTestFunctionAnnotations.test_6cCrj)Nz/def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6): passr_rrrr�test_7�rFzTestFunctionAnnotations.test_7cC�d}|�|�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: passr_�rrrrr�test_8�szTestFunctionAnnotations.test_8cCr�)Nz�def f(
          a: str,
          b: int,
          *,
          c: bool = False,
          **kwargs,
        ) -> None:
            call(c=c, **kwargs,)r_r�rrr�test_9�szTestFunctionAnnotations.test_9cCr�)Nz@def f(
          a: str,
        ) -> None:
            call(a,)r_r�rrr�test_10��zTestFunctionAnnotations.test_10cCr�)NzGdef f(
          a: str = '',
        ) -> None:
            call(a=a,)r_r�rrr�test_11�r�zTestFunctionAnnotations.test_11cCr�)NzHdef f(
          *args: str,
        ) -> None:
            call(*args,)r_r�rrr�test_12�r�zTestFunctionAnnotations.test_12cCr^)Nz)def f(a: str, b: int) -> None: call(a, b)z+def f(a: str, b: int,) -> None: call(a, b,)r_rrrr�test_13�razTestFunctionAnnotations.test_13cCr^)Nz+def f(a: str, *b: int) -> None: call(a, *b)z-def f(a: str, *b: int,) -> None: call(a, *b,)r_rrrr�test_14�razTestFunctionAnnotations.test_14cCr^)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,)r_rrrr�test_15�razTestFunctionAnnotations.test_15cCr^)Nz-def f(a: str, **b: int) -> None: call(a, **b)z/def f(a: str, **b: int,) -> None: call(a, **b,)r_rrrr�test_16�razTestFunctionAnnotations.test_16cCr^)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,)r_rrrr�test_17�razTestFunctionAnnotations.test_17cCr^)Nz/def f(*a: str, **b: int) -> None: call(*a, **b)z1def f(*a: str, **b: int,) -> None: call(*a, **b,)r_rrrr�test_18�razTestFunctionAnnotations.test_18cCr^)Nz$def f(*, b: int=1) -> None: call(*b)z&def f(*, b: int=1,) -> None: call(*b,)r_rrrr�test_19�razTestFunctionAnnotations.test_19cCr^)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,)r_rrrr�test_20�razTestFunctionAnnotations.test_20cCr^)Nz2def f(a: str='', **b: int) -> None: call(a=a, **b)z4def f(a: str='', **b: int,) -> None: call(a=a, **b,)r_rrrr�test_21�razTestFunctionAnnotations.test_21N)rrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�xs,r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestVarAnnotationscCrj)Nz
var1: int = 5r_rrrrr��rFzTestVarAnnotations.test_1cCrj)Nzvar2: [int, str]r_rrrrr��rFzTestVarAnnotations.test_2cCrj)NzCdef f():
    st: str = 'Hello'
    a.b: int = (1, 2)
    return st
r_rrrrr��rFzTestVarAnnotations.test_3cCrj)Nz$def fbad():
    x: int
    print(x)
r_rrrrr��rFzTestVarAnnotations.test_4cCrj)Nzeclass C:
    x: int
    s: str = 'attr'
    z = 2
    def __init__(self, x):
        self.x: int = x
r_rrrrr��rFzTestVarAnnotations.test_5cCrj)Nzlst: List[int] = []r_rrrrr��rFzTestVarAnnotations.test_6N)	rrrr�r�r�r�r�r�rrrrr��sr�c@rW)�
TestExceptcCr�)NzP
            try:
                x
            except E as N:
                yr_r�rrr�test_new��zTestExcept.test_newcCr�)NzN
            try:
                x
            except E, N:
                yr_r�rrr�test_oldr�zTestExcept.test_oldN)rrrr�r�rrrrr��sr�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"cCsH|jD]}dj||dd�}|�|�dj||dd�}|�|�qdS)Nz{p}spamspamspam{s}���)�prz{p}{s}{s}eggs{s}{s}{s})�prefixes�formatrZ)rZpreZsingleZtriplerrr�test_lits

�zTestStringLiterals.test_litN)rrrr�r�rrrrr�	sr�c@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestSetLiteralcCrj)Nzx = {'one'}r_rrrrr� rFzTestSetLiteral.test_1cCrj)Nzx = {'one', 1,}r_rrrrr�#rFzTestSetLiteral.test_2cCrj)Nzx = {'one', 'two', 'three'}r_rrrrr�&rFzTestSetLiteral.test_3cCrj)Nzx = {2, 3, 4,}r_rrrrr�)rFzTestSetLiteral.test_4N)rrrr�r�r�r�rrrrr�s
r�c@r
)�TestIdentifiercCs,|�d�|�d�|�d�|�d�dS)Nu!Örter = 'places'
grün = 'green'u蟒 = a蟒 = 锦蛇 = 1uµ = aµ = µµ = 1uA𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = a_𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 1r_rrrr�test_non_ascii_identifiers0�


z)TestIdentifier.test_non_ascii_identifiersN)rrrr�rrrrr�/rHr�c@rW)�TestNumericLiteralscCrl)NZ0o7777777777777Z0o7324528887rcrrrr�test_new_octal_notation8raz+TestNumericLiterals.test_new_octal_notationcCrl)NZ0b101010Z	0b0101021rcrrrr�test_new_binary_notation<raz,TestNumericLiterals.test_new_binary_notationN)rrrr�r�rrrrr�7sr�c@r
)�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,): passr_rrrr�test_new_syntaxBs




zTestClassDef.test_new_syntaxN)rrrr�rrrrr�ArHr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�TestParserIdempotencyz,A cut-down version of pytree_idempotency.py.c
Cs4tjjrtd|���t|d��}t�|j�d}Wd�n1s#wY|�|d|�t|d|d��}|�	�}Wd�n1sFwYzt
�|�}Wn,ty~zt
�|�}Wnty{}z|�d||f�WYd}~nd}~wwYnwt|�}||kr�tt|||��|�d|�dSdS)	NzParse file: r3rzcan't detect encoding for %s�r)�encodingzParseError on file %s (%s)zIdempotency failed: %s)�testr�verbose�printr;r�detect_encoding�readlineZassertIsNotNoner<rrrrZfail�str�
diff_texts)r�filepath�fpr��sourceZtree�err�newrrr�
parse_fileNs6��
������z TestParserIdempotency.parse_filec	CsHt��D]}|j|d��
|�|�Wd�n1swYqdS)N)r�)rZall_project_filesZsubTestr�)rr�rrr�test_all_project_filescs���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_unpackinghr�z-TestParserIdempotency.test_extended_unpackingN)rrr�__doc__r�r�r�rrrrr�Js
r�c@r�)
�TestLiteralscCst�t�|�d�dS)Nz

)rrr�dedentr�rrrrZqszTestLiterals.validatecCr�)Nu�
            md5test(b"ª" * 80,
                    (b"Test Using Larger Than Block-Size Key "
                     b"and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            r_r�rrr�test_multiline_bytes_literalst�z*TestLiterals.test_multiline_bytes_literalscCr�)Nz�
            b"""
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN">
            """
            r_r�rrr�'test_multiline_bytes_tripquote_literals}r�z4TestLiterals.test_multiline_bytes_tripquote_literalscCr�)Nu�
            md5test("ª" * 80,
                    ("Test Using Larger Than Block-Size Key "
                     "and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            r_r�rrr�test_multiline_str_literals�r�z(TestLiterals.test_multiline_str_literalsN)rrrrZr�r�r�rrrrr�os
		r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�TestNamedAssignmentsz"Also known as the walrus operator.cC�t�d�dS)Nzif f := x(): pass
r�rrrr�test_named_assignment_if�rFz-TestNamedAssignments.test_named_assignment_ifcCr�)Nzwhile f := x(): pass
r�rrrr�test_named_assignment_while�rFz0TestNamedAssignments.test_named_assignment_whilecCr�)Nz0any((lastNum := num) == 1 for num in [1, 2, 3])
r�rrrr�test_named_assignment_generator�rFz4TestNamedAssignments.test_named_assignment_generatorcCr�)Nz-[(lastNum := num) == 1 for num in [1, 2, 3]]
r�rrrr�test_named_assignment_listcomp�rFz3TestNamedAssignments.test_named_assignment_listcompN)rrrr�r�r�r�r�rrrrr��sr�c@rf)�TestPositionalOnlyArgscCr�)Nz!def one_pos_only_arg(a, /): pass
r�rrrr�test_one_pos_only_arg�rFz,TestPositionalOnlyArgs.test_one_pos_only_argcCr�)Nz4def all_markers(a, b=2, /, c, d=4, *, e=5, f): pass
r�rrrr�test_all_markers���z'TestPositionalOnlyArgs.test_all_markerscCr�)Nz�def all_markers_with_args_and_kwargs(
                           aa, b, /, _cc, d, *args, e, f_f, **kwargs,
                   ):
                       pass
r�rrrr�test_all_with_args_and_kwargs�r�z4TestPositionalOnlyArgs.test_all_with_args_and_kwargscCr�)Nz,lambda a, b, /, c, d, *args, e, f, **kw: kw
r�rrrr�test_lambda_soup�r�z'TestPositionalOnlyArgs.test_lambda_soupcCr�)Nzdef func(a,b,/,*,g,e=3): pass
r�rrrr�test_only_positional_or_keyword�rFz6TestPositionalOnlyArgs.test_only_positional_or_keywordN)rrrr�r�r�r�r�rrrrr��sr�c@r
)�TestPickleableExceptioncCs�tdddd�}ttjd�D]4}t�tj||d��}|�|j|j�|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�qdS)Nr4r)r�contextr)Zprotocol)r�rangerBZHIGHEST_PROTOCOL�loadsrCr
�argsr4r�valuer�)rr��protoZerr2rrr�test_ParseError�s�z'TestPickleableException.test_ParseErrorN)rrrr�rrrrr��rHr�c	Cs(|��}|��}tj||||dddd�S)Nz
(original)z(reserialized)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filenamerrrr��s�r��__main__)2r�r�rrrr�rJrRr#rBr'r:r8r!Ztest.supportr�rVZ
lib2to3.pgen2rrZpgen2.parserZlib2to3.pygramr	rZTestCaserrrXr]rbrgror{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�mainrrrr�<module>sV		Q
M va
	%!
�