Your IP : 216.73.216.213


Current Path : /opt/alt/python38/lib64/python3.8/lib2to3/tests/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/lib2to3/tests/__pycache__/test_parser.cpython-38.pyc

U

i�fLZ�@sdZddlmZddlmZmZddlZddlZddlZddlZddl	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*Gd1d2�d2e�Z+Gd3d4�d4ej�Z,d5d6�Z-e.d7k�re�/�dS)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@seZdZdd�ZdS)�
TestDrivercCsJd}t�|�}|�|jdjdjtj�|�|jdjdjtj�dS)Nzprint 1
print 2
rr)r�parse_string�assertEqualZchildren�type�symsZ
print_stmt)�self�s�t�r�>/opt/alt/python38/lib64/python3.8/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�ZsaveZforce)�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�|�}tj
|ddd�|�tj�|��t�|�tj
|ddd�W5t�|�XdS)NTrF)�tempfile�mkdtemp�shutil�rmtree�os�path�join�basenamerr�copyr�_generate_pickle_namer�
assertTrue�exists�unlink)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�t	j
�}tj�||�}tj�||�}t�t	j
|�t�t	j
|�t�
|�}t�
|�}|�||�tj|ddd�|�tj�|��ttj�}d|d<tjtjdd|fg|d�|�tj�|��t|d	��4}	t|d	��}
|j|	��|
��d
d�W5QRXW5QRXW5t�|�XdS)NZsubdirTrZrandomZPYTHONHASHSEEDz-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%r!r"�mkdirr&rrr'rr(ZassertNotEqualrr)r*�dict�environ�
subprocessZ
check_call�sys�
executable�openr�read)rr,Z	tmpsubdirZgrammar_baser-Zgrammar_sub_copyr.Zpickle_sub_nameZsub_envZ
pickle_f_1Z
pickle_f_2rrr�!test_load_grammar_from_subprocess?sF

�
����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�MyModulemsrJzGrammar.txtr=)
rr7�modulesZ
addCleanup�operator�delitemrZload_packaged_grammarrr<)rrJ�grrHr�test_load_packaged_grammarhsz+TestPgen2Caching.test_load_packaged_grammar)rrrrr/�unittestZskipIfr7r8r;rOrrrrr)s

(rc@seZdZdd�Zdd�ZdS)�GrammarTestcCst�|�dS)N)rr�r�coderrr�validatewszGrammarTest.validatecCs0z|�|�Wntk
r"Yn
Xtd��dS)Nz Syntax shouldn't have been valid)rTr�AssertionErrorrRrrr�invalid_syntaxzs
zGrammarTest.invalid_syntaxN)rrrrTrVrrrrrQvsrQc@seZdZdd�ZdS)�TestMatrixMultiplicationcCs|�d�|�d�dS)Nza @ bza @= b�rTrrrr�#test_matrix_multiplication_operator�s
z<TestMatrixMultiplication.test_matrix_multiplication_operatorN)rrrrYrrrrrW�srWc@seZdZdd�ZdS)�
TestYieldFromcCs"|�d�|�d�|�d�dS)Nzyield from xz(yield from x) + yz
yield from�rTrVrrrr�test_yield_from�s

zTestYieldFrom.test_yield_fromN)rrrr\rrrrrZ�srZc@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
        r[rrrr�test_await_expr�s





	



zTestAsyncAwait.test_await_exprcCs"|�d�|�d�|�d�dS)Nz	async = 1z	await = 1zdef async(): passrXrrrr�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: passr[rrrr�test_async_with�s
zTestAsyncAwait.test_async_withcCs|�d�|�d�dS)Nz@async def foo():
                             async with a: passz@def foo():
                                   async with a: passr[rrrr�test_async_for�s
zTestAsyncAwait.test_async_forN)rrrr^r_r`rarrrrr]�s1r]c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestRaiseChangescCs|�d�dS)N�raiserXrrrr�test_2x_style_1�sz TestRaiseChanges.test_2x_style_1cCs|�d�dS)Nz
raise E, VrXrrrr�test_2x_style_2�sz TestRaiseChanges.test_2x_style_2cCs|�d�dS)Nz
raise E, V, TrXrrrr�test_2x_style_3�sz TestRaiseChanges.test_2x_style_3cCs|�d�dS)Nzraise E, V, T, Z�rVrrrr�test_2x_style_invalid_1�sz(TestRaiseChanges.test_2x_style_invalid_1cCs|�d�dS)Nzraise E1 from E2rXrrrr�
test_3x_style�szTestRaiseChanges.test_3x_stylecCs|�d�dS)Nzraise E, V from E1rgrrrr�test_3x_style_invalid_1�sz(TestRaiseChanges.test_3x_style_invalid_1cCs|�d�dS)Nzraise E from E1, E2rgrrrr�test_3x_style_invalid_2�sz(TestRaiseChanges.test_3x_style_invalid_2cCs|�d�dS)Nzraise from E1, E2rgrrrr�test_3x_style_invalid_3�sz(TestRaiseChanges.test_3x_style_invalid_3cCs|�d�dS)Nzraise E fromrgrrrr�test_3x_style_invalid_4�sz(TestRaiseChanges.test_3x_style_invalid_4N)rrrrdrerfrhrirjrkrlrmrrrrrb�srbc@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�TestUnpackingGeneralizationscCs|�d�dS)Nzfunc(1, *(2, 3), 4)rXrrrr�test_mid_positional_star�sz5TestUnpackingGeneralizations.test_mid_positional_starcCs|�d�dS)Nz,func(**{'eggs':'scrambled', 'spam':'fried'})rXrrrr�test_double_star_dict_literal�sz:TestUnpackingGeneralizations.test_double_star_dict_literalcCs|�d�dS)Nz*func(spam='fried', **{'eggs':'scrambled'})rXrrrr�,test_double_star_dict_literal_after_keywords�szITestUnpackingGeneralizations.test_double_star_dict_literal_after_keywordscCs|�d�|�d�dS)Nzfunc(**{'a':2} or {})zfunc(**() or {})rXrrrr�test_double_star_expressions
z8TestUnpackingGeneralizations.test_double_star_expressioncCs|�d�dS)Nzfunc(*[] or [2])rXrrrr�test_star_expressionsz1TestUnpackingGeneralizations.test_star_expressioncCs|�d�dS)Nz[*{2}, 3, *[4]]rXrrrr�test_list_displaysz.TestUnpackingGeneralizations.test_list_displaycCs|�d�dS)Nz{*{2}, 3, *[4]}rXrrrr�test_set_display
sz-TestUnpackingGeneralizations.test_set_displaycCs|�d�dS)Nz{**{}}rXrrrr�test_dict_display_1
sz0TestUnpackingGeneralizations.test_dict_display_1cCs|�d�dS)Nz{**{}, 3:4, **{5:6, 7:8}}rXrrrr�test_dict_display_2sz0TestUnpackingGeneralizations.test_dict_display_2cCs|�d�dS)Nzfunc(* [] or [1])rXrrrr�test_complex_star_expressionsz9TestUnpackingGeneralizations.test_complex_star_expressioncCs|�d�dS)Nz5func(**{1: 3} if False else {x: x for x in range(3)})rXrrrr�#test_complex_double_star_expressionsz@TestUnpackingGeneralizations.test_complex_double_star_expressioncCs|�d�dS)Nzf(a, *b, *c, d)rXrrrr�test_argument_unpacking_1sz6TestUnpackingGeneralizations.test_argument_unpacking_1cCs|�d�dS)Nzf(**a, **b)rXrrrr�test_argument_unpacking_2sz6TestUnpackingGeneralizations.test_argument_unpacking_2cCs|�d�dS)Nzf(2, *a, *b, **b, **c, **d)rXrrrr�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,)rXrrrr�test_trailing_commas_1"s
z3TestUnpackingGeneralizations.test_trailing_commas_1cCs|�d�|�d�dS)Nzdef f(a, *b): call(a, *b)zdef f(a, *b,): call(a, *b,)rXrrrr�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,)rXrrrr�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,)rXrrrr�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,)rXrrrr�test_trailing_commas_52s
z3TestUnpackingGeneralizations.test_trailing_commas_5cCs|�d�|�d�dS)Nzdef f(*a, **b): call(*a, **b)zdef f(*a, **b,): call(*a, **b,)rXrrrr�test_trailing_commas_66s
z3TestUnpackingGeneralizations.test_trailing_commas_6cCs|�d�|�d�dS)Nzdef f(*, b=1): call(*b)zdef f(*, b=1,): call(*b,)rXrrrr�test_trailing_commas_7:s
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,)rXrrrr�test_trailing_commas_8>s
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,)rXrrrr�test_trailing_commas_9Bs
z3TestUnpackingGeneralizations.test_trailing_commas_9cCs|�d�|�d�dS)Nzf = lambda a, b: call(a, b)zf = lambda a, b,: call(a, b,)rXrrrr�test_trailing_commas_lambda_1Fs
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_1cCs|�d�|�d�dS)Nzf = lambda a, *b: call(a, *b)zf = lambda a, *b,: call(a, *b,)rXrrrr�test_trailing_commas_lambda_2Js
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,)rXrrrr�test_trailing_commas_lambda_3Ns
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,)rXrrrr�test_trailing_commas_lambda_4Rs
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,)rXrrrr�test_trailing_commas_lambda_5Vs
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,)rXrrrr�test_trailing_commas_lambda_6Zs
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_6cCs|�d�|�d�dS)Nzf = lambda *, b=1: call(*b)zf = lambda *, b=1,: call(*b,)rXrrrr�test_trailing_commas_lambda_7^s
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,)rXrrrr�test_trailing_commas_lambda_8bs
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,)rXrrrr�test_trailing_commas_lambda_9fs
z:TestUnpackingGeneralizations.test_trailing_commas_lambda_9N)#rrrrorprqrrrsrtrurvrwrxryrzr{r|r}r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrn�s@rnc@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: passrXrrrr�test_1mszTestFunctionAnnotations.test_1cCs|�d�dS)Nzdef f(x:int): passrXrrrr�test_2pszTestFunctionAnnotations.test_2cCs|�d�dS)Nzdef f(*x:str): passrXrrrr�test_3sszTestFunctionAnnotations.test_3cCs|�d�dS)Nzdef f(**x:float): passrXrrrr�test_4vszTestFunctionAnnotations.test_4cCs|�d�dS)Nzdef f(x, y:1+2): passrXrrrr�test_5yszTestFunctionAnnotations.test_5cCs|�d�dS)Nzdef f(a, (b:1, c:2, d)): passrXrrrr�test_6|szTestFunctionAnnotations.test_6cCs|�d�dS)Nz/def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6): passrXrrrr�test_7szTestFunctionAnnotations.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: passrX�rrrrr�test_8�szTestFunctionAnnotations.test_8cCsd}|�|�dS)Nz�def f(
          a: str,
          b: int,
          *,
          c: bool = False,
          **kwargs,
        ) -> None:
            call(c=c, **kwargs,)rXr�rrr�test_9�szTestFunctionAnnotations.test_9cCsd}|�|�dS)Nz@def f(
          a: str,
        ) -> None:
            call(a,)rXr�rrr�test_10�szTestFunctionAnnotations.test_10cCsd}|�|�dS)NzGdef f(
          a: str = '',
        ) -> None:
            call(a=a,)rXr�rrr�test_11�szTestFunctionAnnotations.test_11cCsd}|�|�dS)NzHdef f(
          *args: str,
        ) -> None:
            call(*args,)rXr�rrr�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,)rXrrrr�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,)rXrrrr�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,)rXrrrr�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,)rXrrrr�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,)rXrrrr�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,)rXrrrr�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,)rXrrrr�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,)rXrrrr�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,)rXrrrr�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�ls*r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestVarAnnotationscCs|�d�dS)Nz
var1: int = 5rXrrrrr��szTestVarAnnotations.test_1cCs|�d�dS)Nzvar2: [int, str]rXrrrrr��szTestVarAnnotations.test_2cCs|�d�dS)NzCdef f():
    st: str = 'Hello'
    a.b: int = (1, 2)
    return st
rXrrrrr��szTestVarAnnotations.test_3cCs|�d�dS)Nz$def fbad():
    x: int
    print(x)
rXrrrrr��szTestVarAnnotations.test_4cCs|�d�dS)Nzeclass C:
    x: int
    s: str = 'attr'
    z = 2
    def __init__(self, x):
        self.x: int = x
rXrrrrr��szTestVarAnnotations.test_5cCs|�d�dS)Nzlst: List[int] = []rXrrrrr��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:
                yrXr�rrr�test_new�szTestExcept.test_newcCsd}|�|�dS)NzN
            try:
                x
            except E, N:
                yrXr�rrr�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"cCsH|jD]<}dj||dd�}|�|�dj||dd�}|�|�qdS)Nz{p}spamspamspam{s}���)�prz{p}{s}{s}eggs{s}{s}{s})�prefixes�formatrT)rZpreZsingleZtriplerrr�test_lit
s


zTestStringLiterals.test_litN)rrrr�r�rrrrr��sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestSetLiteralcCs|�d�dS)Nzx = {'one'}rXrrrrr�szTestSetLiteral.test_1cCs|�d�dS)Nzx = {'one', 1,}rXrrrrr�szTestSetLiteral.test_2cCs|�d�dS)Nzx = {'one', 'two', 'three'}rXrrrrr�szTestSetLiteral.test_3cCs|�d�dS)Nzx = {2, 3, 4,}rXrrrrr�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_𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 1rXrrrr�test_non_ascii_identifiers$s


z(TestIdentfier.test_non_ascii_identifiersN)rrrr�rrrrr�#sr�c@seZdZdd�Zdd�ZdS)�TestNumericLiteralscCs|�d�|�d�dS)NZ0o7777777777777Z0o7324528887r[rrrr�test_new_octal_notation,s
z+TestNumericLiterals.test_new_octal_notationcCs|�d�|�d�dS)NZ0b101010Z	0b0101021r[rrrr�test_new_binary_notation0s
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,): passrXrrrr�test_new_syntax6s




zTestClassDef.test_new_syntaxN)rrrr�rrrrr�5sr�c@s eZdZdZdd�Zdd�ZdS)�TestParserIdempotencyz,A cut-down version of pytree_idempotency.py.cCst��D]�}t|d��}t�|j�d}W5QRX|�|d|�t|d|d��}|��}W5QRXzt�	|�}WnXt
k
r�zt�	|�}Wn4t
k
r�}z|�d||f�W5d}~XYnXYnXt
|�}||krtt|||��|�d|�qdS)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_filesBs&�*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
�rrrrrr�test_extended_unpackingVs


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

)rrr�dedentr�rrrrT_szTestLiterals.validatecCsd}|�|�dS)Nu�
            md5test(b"ª" * 80,
                    (b"Test Using Larger Than Block-Size Key "
                     b"and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            rXr�rrr�test_multiline_bytes_literalsbsz*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">
            """
            rXr�rrr�'test_multiline_bytes_tripquote_literalsksz4TestLiterals.test_multiline_bytes_tripquote_literalscCsd}|�|�dS)Nu�
            md5test("ª" * 80,
                    ("Test Using Larger Than Block-Size Key "
                     "and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            rXr�rrr�test_multiline_str_literalstsz(TestLiterals.test_multiline_str_literalsN)rrrrTr�r�r�rrrrr�]s		r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�TestNamedAssignmentsz"Also known as the walrus operator.cCst�d�dS)Nzif f := x(): pass
r�rrrr�test_named_assignment_if�sz-TestNamedAssignments.test_named_assignment_ifcCst�d�dS)Nzwhile f := x(): pass
r�rrrr�test_named_assignment_while�sz0TestNamedAssignments.test_named_assignment_whilecCst�d�dS)Nz0any((lastNum := num) == 1 for num in [1, 2, 3])
r�rrrr�test_named_assignment_generator�sz4TestNamedAssignments.test_named_assignment_generatorcCst�d�dS)Nz-[(lastNum := num) == 1 for num in [1, 2, 3]]
r�rrrr�test_named_assignment_listcomp�sz3TestNamedAssignments.test_named_assignment_listcompN)rrrr�r�r�r�r�rrrrr�~s
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestPositionalOnlyArgscCst�d�dS)Nz!def one_pos_only_arg(a, /): pass
r�rrrr�test_one_pos_only_arg�sz,TestPositionalOnlyArgs.test_one_pos_only_argcCst�d�dS)Nz4def all_markers(a, b=2, /, c, d=4, *, e=5, f): pass
r�rrrr�test_all_markers�s�z'TestPositionalOnlyArgs.test_all_markerscCst�d�dS)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�s�z4TestPositionalOnlyArgs.test_all_with_args_and_kwargscCst�d�dS)Nz,lambda a, b, /, c, d, *args, e, f, **kw: kw
r�rrrr�test_lambda_soup�s�z'TestPositionalOnlyArgs.test_lambda_soupcCst�d�dS)Nzdef func(a,b,/,*,g,e=3): pass
r�rrrr�test_only_positional_or_keyword�sz6TestPositionalOnlyArgs.test_only_positional_or_keywordN)rrrr�r�r�r�r�rrrrr��s
r�c@seZdZdd�ZdS)�TestPickleableExceptioncCs�tdddd�}ttjd�D]h}t�tj||d��}|�|j|j�|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�qdS)Nr2r)r�contextr)Zprotocol)r�ranger>ZHIGHEST_PROTOCOL�loadsr?r�argsr2r
�valuer�)rr��protoZerr2rrr�test_ParseError�sz'TestPickleableException.test_ParseErrorN)rrrr�rrrrr��sr�c	Cs(|��}|��}tj||||dddd�S)Nz
(original)z(reserialized)�)Zlineterm)�
splitlines�difflibZunified_diff)�a�b�filenamerrrr��s�r��__main__)0r�r�rrrr�rDrLr#r>r!r6r7rrPZ
lib2to3.pgen2rrZpgen2.parserZlib2to3.pygramr	rZTestCaser
rrQrWrZr]rbrnr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�mainrrrr�<module>sP		M
F va
	!