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.10/lib2to3/tests/__pycache__/test_parser.cpython-310.opt-1.pyc
o

�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�6/usr/local/lib/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��save�force)�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)NZsubdirTr�randomZPYTHONHASHSEEDzs
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(rr r)r*rr+ZassertNotEqualrr,r-�dict�environ�sys�
executable�
subprocess�
check_call�openr
�readr/)rr0Z	tmpsubdirZgrammar_baser1Zgrammar_sub_copyr2Zpickle_sub_nameZsub_env�coder7�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)rrrrIrrrr�MyLoadero�rKcs eZdZdZej�����ZdS)z=TestPgen2Caching.test_load_packaged_grammar.<locals>.MyModuleZparsertestmoduleN)rrr�__file__�	importlib�util�spec_from_loader�__spec__r�rK�modnamerr�MyModulersrTzGrammar.txtrE)
rr;�modulesZ
addCleanup�operator�delitemrZload_packaged_grammarr
rD)rrT�grrRr�test_load_packaged_grammarmsz+TestPgen2Caching.test_load_packaged_grammar)rrrr"r3�unittestZskipIfr;r<rCrYrrrrr*s
,rc@�eZdZdd�Zdd�ZdS)�GrammarTestcCst�|�dS)N)rr�rrArrr�validate|rJzGrammarTest.validatecCs*z
|�|�Wtd��tyYdSw)Nz Syntax shouldn't have been valid)r^r�AssertionErrorr]rrr�invalid_syntaxs��zGrammarTest.invalid_syntaxN)rrrr^r`rrrrr\{sr\c@r
)�TestMatrixMultiplicationcC�|�d�|�d�dS)Nza @ bza @= b�r^r!rrr�#test_matrix_multiplication_operator��
z<TestMatrixMultiplication.test_matrix_multiplication_operatorN)rrrrdrrrrra�rLrac@r
)�
TestYieldFromcCs"|�d�|�d�|�d�dS)Nzyield from xz(yield from x) + yz
yield from�r^r`r!rrr�test_yield_from��

zTestYieldFrom.test_yield_fromN)rrrrhrrrrrf�rLrfc@�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
        rgr!rrr�test_await_expr�s






	


zTestAsyncAwait.test_await_exprcCs"|�d�|�d�|�d�dS)Nz	async = 1z	await = 1zdef async(): passrcr!rrr�test_async_var�rizTestAsyncAwait.test_async_varcC�|�d�dS)NzDasync def foo():
                             async for a in b: passrcr!rrr�test_async_for�rJzTestAsyncAwait.test_async_forcC�|�d�|�d�dS)Nz@async def foo():
                             async with a: passz@def foo():
                                   async with a: passrgr!rrr�test_async_with�s
zTestAsyncAwait.test_async_withcCrb)NzLasync def foo():
                   return (i * 2 async for i in arange(42))zFdef foo():
                   return (i * 2 async for i in arange(42))rcr!rrr�test_async_generator�s��z#TestAsyncAwait.test_async_generatorN)rrrrlrmrorqrrrrrrrk�s1rkc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestRaiseChangescCrn)N�raisercr!rrr�test_2x_style_1�rJz TestRaiseChanges.test_2x_style_1cCrn)Nz
raise E, Vrcr!rrr�test_2x_style_2�rJz TestRaiseChanges.test_2x_style_2cCrn)Nz
raise E, V, Trcr!rrr�test_2x_style_3�rJz TestRaiseChanges.test_2x_style_3cCrn)Nzraise E, V, T, Z�r`r!rrr�test_2x_style_invalid_1�rJz(TestRaiseChanges.test_2x_style_invalid_1cCrn)Nzraise E1 from E2rcr!rrr�
test_3x_style�rJzTestRaiseChanges.test_3x_stylecCrn)Nzraise E, V from E1rxr!rrr�test_3x_style_invalid_1�rJz(TestRaiseChanges.test_3x_style_invalid_1cCrn)Nzraise E from E1, E2rxr!rrr�test_3x_style_invalid_2�rJz(TestRaiseChanges.test_3x_style_invalid_2cCrn)Nzraise from E1, E2rxr!rrr�test_3x_style_invalid_3�rJz(TestRaiseChanges.test_3x_style_invalid_3cCrn)Nzraise E fromrxr!rrr�test_3x_style_invalid_4�rJz(TestRaiseChanges.test_3x_style_invalid_4N)rrrrurvrwryrzr{r|r}r~rrrrrs�srsc@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�TestUnpackingGeneralizationscCrn)Nzfunc(1, *(2, 3), 4)rcr!rrr�test_mid_positional_starrJz5TestUnpackingGeneralizations.test_mid_positional_starcCrn)Nz,func(**{'eggs':'scrambled', 'spam':'fried'})rcr!rrr�test_double_star_dict_literalrJz:TestUnpackingGeneralizations.test_double_star_dict_literalcCrn)Nz*func(spam='fried', **{'eggs':'scrambled'})rcr!rrr�,test_double_star_dict_literal_after_keywords	rJzITestUnpackingGeneralizations.test_double_star_dict_literal_after_keywordscCrb)Nzfunc(**{'a':2} or {})zfunc(**() or {})rcr!rrr�test_double_star_expressionrez8TestUnpackingGeneralizations.test_double_star_expressioncCrn)Nzfunc(*[] or [2])rcr!rrr�test_star_expressionrJz1TestUnpackingGeneralizations.test_star_expressioncCrn)Nz[*{2}, 3, *[4]]rcr!rrr�test_list_displayrJz.TestUnpackingGeneralizations.test_list_displaycCrn)Nz{*{2}, 3, *[4]}rcr!rrr�test_set_displayrJz-TestUnpackingGeneralizations.test_set_displaycCrn)Nz{**{}}rcr!rrr�test_dict_display_1rJz0TestUnpackingGeneralizations.test_dict_display_1cCrn)Nz{**{}, 3:4, **{5:6, 7:8}}rcr!rrr�test_dict_display_2rJz0TestUnpackingGeneralizations.test_dict_display_2cCrn)Nzfunc(* [] or [1])rcr!rrr�test_complex_star_expressionrJz9TestUnpackingGeneralizations.test_complex_star_expressioncCrn)Nz5func(**{1: 3} if False else {x: x for x in range(3)})rcr!rrr�#test_complex_double_star_expression"rJz@TestUnpackingGeneralizations.test_complex_double_star_expressioncCrn)Nzf(a, *b, *c, d)rcr!rrr�test_argument_unpacking_1%rJz6TestUnpackingGeneralizations.test_argument_unpacking_1cCrn)Nzf(**a, **b)rcr!rrr�test_argument_unpacking_2(rJz6TestUnpackingGeneralizations.test_argument_unpacking_2cCrn)Nzf(2, *a, *b, **b, **c, **d)rcr!rrr�test_argument_unpacking_3+rJz6TestUnpackingGeneralizations.test_argument_unpacking_3cCrb)Nzdef f(a, b): call(a, b)zdef f(a, b,): call(a, b,)rcr!rrr�test_trailing_commas_1.rez3TestUnpackingGeneralizations.test_trailing_commas_1cCrb)Nzdef f(a, *b): call(a, *b)zdef f(a, *b,): call(a, *b,)rcr!rrr�test_trailing_commas_22rez3TestUnpackingGeneralizations.test_trailing_commas_2cCrb)Nzdef f(a, b=1): call(a, b=1)zdef f(a, b=1,): call(a, b=1,)rcr!rrr�test_trailing_commas_36rez3TestUnpackingGeneralizations.test_trailing_commas_3cCrb)Nzdef f(a, **b): call(a, **b)zdef f(a, **b,): call(a, **b,)rcr!rrr�test_trailing_commas_4:rez3TestUnpackingGeneralizations.test_trailing_commas_4cCrb)Nzdef f(*a, b=1): call(*a, b=1)zdef f(*a, b=1,): call(*a, b=1,)rcr!rrr�test_trailing_commas_5>rez3TestUnpackingGeneralizations.test_trailing_commas_5cCrb)Nzdef f(*a, **b): call(*a, **b)zdef f(*a, **b,): call(*a, **b,)rcr!rrr�test_trailing_commas_6Brez3TestUnpackingGeneralizations.test_trailing_commas_6cCrb)Nzdef f(*, b=1): call(*b)zdef f(*, b=1,): call(*b,)rcr!rrr�test_trailing_commas_7Frez3TestUnpackingGeneralizations.test_trailing_commas_7cCrb)Nzdef f(a=1, b=2): call(a=1, b=2)z!def f(a=1, b=2,): call(a=1, b=2,)rcr!rrr�test_trailing_commas_8Jrez3TestUnpackingGeneralizations.test_trailing_commas_8cCrb)Nzdef f(a=1, **b): call(a=1, **b)z!def f(a=1, **b,): call(a=1, **b,)rcr!rrr�test_trailing_commas_9Nrez3TestUnpackingGeneralizations.test_trailing_commas_9cCrb)Nzf = lambda a, b: call(a, b)zf = lambda a, b,: call(a, b,)rcr!rrr�test_trailing_commas_lambda_1Rrez:TestUnpackingGeneralizations.test_trailing_commas_lambda_1cCrb)Nzf = lambda a, *b: call(a, *b)zf = lambda a, *b,: call(a, *b,)rcr!rrr�test_trailing_commas_lambda_2Vrez:TestUnpackingGeneralizations.test_trailing_commas_lambda_2cCrb)Nzf = lambda a, b=1: call(a, b=1)z!f = lambda a, b=1,: call(a, b=1,)rcr!rrr�test_trailing_commas_lambda_3Zrez:TestUnpackingGeneralizations.test_trailing_commas_lambda_3cCrb)Nzf = lambda a, **b: call(a, **b)z!f = lambda a, **b,: call(a, **b,)rcr!rrr�test_trailing_commas_lambda_4^rez:TestUnpackingGeneralizations.test_trailing_commas_lambda_4cCrb)Nz!f = lambda *a, b=1: call(*a, b=1)z#f = lambda *a, b=1,: call(*a, b=1,)rcr!rrr�test_trailing_commas_lambda_5brez:TestUnpackingGeneralizations.test_trailing_commas_lambda_5cCrb)Nz!f = lambda *a, **b: call(*a, **b)z#f = lambda *a, **b,: call(*a, **b,)rcr!rrr�test_trailing_commas_lambda_6frez:TestUnpackingGeneralizations.test_trailing_commas_lambda_6cCrb)Nzf = lambda *, b=1: call(*b)zf = lambda *, b=1,: call(*b,)rcr!rrr�test_trailing_commas_lambda_7jrez:TestUnpackingGeneralizations.test_trailing_commas_lambda_7cCrb)Nz#f = lambda a=1, b=2: call(a=1, b=2)z%f = lambda a=1, b=2,: call(a=1, b=2,)rcr!rrr�test_trailing_commas_lambda_8nrez:TestUnpackingGeneralizations.test_trailing_commas_lambda_8cCrb)Nz#f = lambda a=1, **b: call(a=1, **b)z%f = lambda a=1, **b,: call(a=1, **b,)rcr!rrr�test_trailing_commas_lambda_9rrez:TestUnpackingGeneralizations.test_trailing_commas_lambda_9N)#rrrr�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�rrrrrsBrc@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),�TestFunctionAnnotationscCrn)Nzdef f(x) -> list: passrcr!rrr�test_1yrJzTestFunctionAnnotations.test_1cCrn)Nzdef f(x:int): passrcr!rrr�test_2|rJzTestFunctionAnnotations.test_2cCrn)Nzdef f(*x:str): passrcr!rrr�test_3rJzTestFunctionAnnotations.test_3cCrn)Nzdef f(**x:float): passrcr!rrr�test_4�rJzTestFunctionAnnotations.test_4cCrn)Nzdef f(x, y:1+2): passrcr!rrr�test_5�rJzTestFunctionAnnotations.test_5cCrn)Nzdef f(a, (b:1, c:2, d)): passrcr!rrr�test_6�rJzTestFunctionAnnotations.test_6cCrn)Nz/def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6): passrcr!rrr�test_7�rJzTestFunctionAnnotations.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: passrc�rrrrr�test_8�szTestFunctionAnnotations.test_8cCr�)Nz�def f(
          a: str,
          b: int,
          *,
          c: bool = False,
          **kwargs,
        ) -> None:
            call(c=c, **kwargs,)rcr�rrr�test_9�szTestFunctionAnnotations.test_9cCr�)Nz@def f(
          a: str,
        ) -> None:
            call(a,)rcr�rrr�test_10��zTestFunctionAnnotations.test_10cCr�)NzGdef f(
          a: str = '',
        ) -> None:
            call(a=a,)rcr�rrr�test_11�r�zTestFunctionAnnotations.test_11cCr�)NzHdef f(
          *args: str,
        ) -> None:
            call(*args,)rcr�rrr�test_12�r�zTestFunctionAnnotations.test_12cCrb)Nz)def f(a: str, b: int) -> None: call(a, b)z+def f(a: str, b: int,) -> None: call(a, b,)rcr!rrr�test_13�rezTestFunctionAnnotations.test_13cCrb)Nz+def f(a: str, *b: int) -> None: call(a, *b)z-def f(a: str, *b: int,) -> None: call(a, *b,)rcr!rrr�test_14�rezTestFunctionAnnotations.test_14cCrb)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,)rcr!rrr�test_15�rezTestFunctionAnnotations.test_15cCrb)Nz-def f(a: str, **b: int) -> None: call(a, **b)z/def f(a: str, **b: int,) -> None: call(a, **b,)rcr!rrr�test_16�rezTestFunctionAnnotations.test_16cCrb)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,)rcr!rrr�test_17�rezTestFunctionAnnotations.test_17cCrb)Nz/def f(*a: str, **b: int) -> None: call(*a, **b)z1def f(*a: str, **b: int,) -> None: call(*a, **b,)rcr!rrr�test_18�rezTestFunctionAnnotations.test_18cCrb)Nz$def f(*, b: int=1) -> None: call(*b)z&def f(*, b: int=1,) -> None: call(*b,)rcr!rrr�test_19�rezTestFunctionAnnotations.test_19cCrb)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,)rcr!rrr�test_20�rezTestFunctionAnnotations.test_20cCrb)Nz2def f(a: str='', **b: int) -> None: call(a=a, **b)z4def f(a: str='', **b: int,) -> None: call(a=a, **b,)rcr!rrr�test_21�rezTestFunctionAnnotations.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)�TestVarAnnotationscCrn)Nz
var1: int = 5rcr!rrrr��rJzTestVarAnnotations.test_1cCrn)Nzvar2: [int, str]rcr!rrrr��rJzTestVarAnnotations.test_2cCrn)NzCdef f():
    st: str = 'Hello'
    a.b: int = (1, 2)
    return st
rcr!rrrr��rJzTestVarAnnotations.test_3cCrn)Nz$def fbad():
    x: int
    print(x)
rcr!rrrr��rJzTestVarAnnotations.test_4cCrn)Nzeclass C:
    x: int
    s: str = 'attr'
    z = 2
    def __init__(self, x):
        self.x: int = x
rcr!rrrr��rJzTestVarAnnotations.test_5cCrn)Nzlst: List[int] = []rcr!rrrr��rJzTestVarAnnotations.test_6N)	rrrr�r�r�r�r�r�rrrrr��sr�c@r[)�
TestExceptcCr�)NzP
            try:
                x
            except E as N:
                yrcr�rrr�test_new��zTestExcept.test_newcCr�)NzN
            try:
                x
            except E, N:
                yrcr�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�formatr^)r�preZsingleZtriplerrr�test_lits

�zTestStringLiterals.test_litN)rrrr�r�rrrrr�	sr�c@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestSetLiteralcCrn)Nzx = {'one'}rcr!rrrr� rJzTestSetLiteral.test_1cCrn)Nzx = {'one', 1,}rcr!rrrr�#rJzTestSetLiteral.test_2cCrn)Nzx = {'one', 'two', 'three'}rcr!rrrr�&rJzTestSetLiteral.test_3cCrn)Nzx = {2, 3, 4,}rcr!rrrr�)rJzTestSetLiteral.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_𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 1rcr!rrr�test_non_ascii_identifiers0�


z)TestIdentifier.test_non_ascii_identifiersN)rrrr�rrrrr�/rLr�c@r[)�TestNumericLiteralscCrp)NZ0o7777777777777Z0o7324528887rgr!rrr�test_new_octal_notation8rez+TestNumericLiterals.test_new_octal_notationcCrp)NZ0b101010Z	0b0101021rgr!rrr�test_new_binary_notation<rez,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,): passrcr!rrr�test_new_syntaxBs




zTestClassDef.test_new_syntaxN)rrrr�rrrrr�ArLr�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: r6rzcan'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r!rrr�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�rrrr^qszTestLiterals.validatecCr�)Nu�
            md5test(b"ª" * 80,
                    (b"Test Using Larger Than Block-Size Key "
                     b"and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            rcr�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">
            """
            rcr�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")
            rcr�rrr�test_multiline_str_literals�r�z(TestLiterals.test_multiline_str_literalsN)rrrr^r�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�r!rrr�test_named_assignment_if�rJz-TestNamedAssignments.test_named_assignment_ifcCr�)Nzwhile f := x(): pass
r�r!rrr�test_named_assignment_while�rJz0TestNamedAssignments.test_named_assignment_whilecCr�)Nz0any((lastNum := num) == 1 for num in [1, 2, 3])
r�r!rrr�test_named_assignment_generator�rJz4TestNamedAssignments.test_named_assignment_generatorcCr�)Nz-[(lastNum := num) == 1 for num in [1, 2, 3]]
r�r!rrr�test_named_assignment_listcomp�rJz3TestNamedAssignments.test_named_assignment_listcompN)rrrr�r�r�r�r�rrrrr��sr�c@rj)�TestPositionalOnlyArgscCr�)Nz!def one_pos_only_arg(a, /): pass
r�r!rrr�test_one_pos_only_arg�rJz,TestPositionalOnlyArgs.test_one_pos_only_argcCr�)Nz4def all_markers(a, b=2, /, c, d=4, *, e=5, f): pass
r�r!rrr�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�r!rrr�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�r!rrr�test_lambda_soup�r�z'TestPositionalOnlyArgs.test_lambda_soupcCr�)Nzdef func(a,b,/,*,g,e=3): pass
r�r!rrr�test_only_positional_or_keyword�rJz6TestPositionalOnlyArgs.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)Nr7r)r�contextr)�protocol)r�rangerF�HIGHEST_PROTOCOL�loadsrGr
�argsr7r�valuer�)rr��protoZerr2rrr�test_ParseError�s�z'TestPickleableException.test_ParseErrorN)rrrrrrrrr��rLr�c	Cs(|��}|��}tj||||dddd�S)Nz
(original)z(reserialized)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filenamerrrr��s�r��__main__)2r�rrrrrrNrVr%rFr)r=r;r#Ztest.supportr�rZZ
lib2to3.pgen2rrZpgen2.parserZlib2to3.pygramr	rZTestCaserrr\rarfrkrsrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�mainrrrr�<module>sV		Q
M va
	%!
�