Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/lib2to3/tests/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/lib2to3/tests/__pycache__/test_util.cpython-39.opt-2.pyc

a

��g�R�@sddlmZddlmZmZddlmZddlmZm	Z	m
Z
mZddlm
Z
ddd�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZdS)�)�support�)�Node�Leaf)�
fixer_util)�Attr�Name�Call�Comma)�tokencCs,t�|�}t|�D]}|jd}qd|_|S)Nr)rZparse_string�range�children�parent)�code�strip_levelsZtree�i�r�3/usr/local/lib/python3.9/lib2to3/tests/test_util.py�parses

rc@seZdZdd�ZdS)�
MacroTestCasecCs0t|ttf�rttjj|�}|�t|�|�dS�N)	�
isinstance�tuple�listrrZsymsZsimple_stmt�assertEqual�str)�self�node�stringrrr�	assertStrszMacroTestCase.assertStrN)�__name__�
__module__�__qualname__rrrrrrsrc@s$eZdZdd�Zdd�Zdd�ZdS)�
Test_is_tuplecCst�t|dd��S�N��r)r�is_tupler�rrrrrr'szTest_is_tuple.is_tuplecCsT|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��dS)Nz(a, b)z(a, (b, c))z((a, (b, c)),)z(a,)z())�
assertTruer'�rrrr�
test_valid s
zTest_is_tuple.test_validcCs$|�|�d��|�|�d��dS)Nz(a)z('foo') % (b, c))�assertFalser'r*rrr�test_invalid'szTest_is_tuple.test_invalidN)r r!r"r'r+r-rrrrr#sr#c@s$eZdZdd�Zdd�Zdd�ZdS)�Test_is_listcCst�t|dd��Sr$)r�is_listrr(rrrr/-szTest_is_list.is_listcCsT|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��dS)Nz[]z[a]z[a, b]z[a, [b, c]]z[[a, [b, c]],])r)r/r*rrrr+0s
zTest_is_list.test_validcCs|�|�d��dS)Nz[]+[])r,r/r*rrrr-7szTest_is_list.test_invalidN)r r!r"r/r+r-rrrrr.,sr.c@seZdZdd�Zdd�ZdS)�	Test_AttrcCs@tddd�}|�ttd�td��d�|�t|td��d�dS)Nzfoo()r%r&�a�b�a.bzfoo().b)rrrr)r�callrrr�test<szTest_Attr.testcCs&ttd�td��}|�t|�t�dS)Nr1r2)rrr�typer)r�attrrrr�test_returnsBszTest_Attr.test_returnsN)r r!r"r5r8rrrrr0;sr0c@seZdZdd�ZdS)�	Test_NamecCs8|�td�d�|�td�d�|�tddd�d�dS)Nr1z
foo.foo().barr2��prefixZba)rrr*rrrr5HszTest_Name.testN)r r!r"r5rrrrr9Gsr9c@seZdZddd�Zdd�ZdS)�	Test_CallNcCsFg}t|t�r6|D]}|�|�|�t��q|��tt|�||�Sr)rr�appendr
�popr	r)r�name�argsr;r
�argrrr�_CallOs

zTest_Call._Callc	Cs�dttjd�ttjd�ttjd�gttjd�ttjd�ttjd�ttjd�gttjd�ttjddd�gg}|�|�d	�d
�|�|�d|d�d�|�|�d|d�d
�|�|jd|ddd�d�dS)Nrr%��r2�j� r:�AzA()zb(1,2,3)za.b().cza.b().c(1,3,2,4)�dz d(b, j))rr�NUMBER�STRINGrrB)rZkidsrrrr5Ys
���zTest_Call.test)NN)r r!r"rBr5rrrrr<Ns

r<c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�Test_does_tree_importcCs<t�||�}|r|S|jD]}|�||�}|r|SqdSr)r�find_bindingr
�_find_bind_rec)rr?r�c�childrrrrMhs

z$Test_does_tree_import._find_bind_reccCs"t|�}|�d|�}t�|||�S)N�start)rrMr�does_tree_import)r�packager?rrrrrrQqsz&Test_does_tree_import.does_tree_importcCs�d}|D]J\}}}|�|||d|�}|�|�|�|||d|�}|�|�qd}|D]J\}}}|�|||d|�}|�|�|�|||d|�}|�|�q\dS)N))r1r1�from a import b)�a.dr1�from a.d import b)zd.ar1�from d.a import b)Nr1�import b)Nr1�import b, c, d�
))r1r1�from a import a)�xr1�from x import a)r[r1�from x import b, c, a, d)�x.br1�from x.b import a)r^r1�from x.b import b, c, a, d)Nr1�import a)Nr1�import b, c, a, d)rQr,r))rrZ
failing_testsrRr?�import_�nZ
passing_testsrrr�try_withws

zTest_does_tree_import.try_withcCs|�d�dS)Nzdef foo():
	bar.baz()
	start=3)rer*rrr�test_in_function�sz&Test_does_tree_import.test_in_functionN)r r!r"rMrQrerfrrrrrKgs	rKc@s�eZdZd4dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZdS)5�Test_find_bindingNcCst�|t|�|�Sr)rrLr)rr?rrRrrrrL�szTest_find_binding.find_bindingcCsp|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr1za = bz
a = [b, c, d]z	a = foo()za = foo().foo.foo[6][foo]zfoo = azfoo = (a, b, c)�r)rLr,r*rrr�test_simple_assignment�sz(Test_find_binding.test_simple_assignmentcCsp|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr1z(a,) = bz(a, b, c) = [b, c, d]z(c, (d, a), b) = foo()z(a, b) = foo().foo[6][foo]z(foo, b) = (b, a)z(foo, (b, c)) = (a, b, c)rhr*rrr�test_tuple_assignment�sz'Test_find_binding.test_tuple_assignmentcCsp|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr1z[a] = bz[a, b, c] = [b, c, d]z[c, [d, a], b] = foo()z[a, b] = foo().foo[a][foo]z[foo, b] = (b, a)z[foo, [b, c]] = (a, b, c)rhr*rrr�test_list_assignment�sz&Test_find_binding.test_list_assignmentcCsL|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr1z	foo.a = 5z
foo[a] = 5z
foo(a) = 5z
foo(a, b) = 5�r,rLr*rrr�test_invalid_assignments�sz*Test_find_binding.test_invalid_assignmentscCsL|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr1rarbrWrXrhr*rrr�test_simple_import�sz$Test_find_binding.test_simple_importcCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd	��dS)
Nr1r\rZr]r_r`rSrUrVrhr*rrr�test_from_import�sz"Test_find_binding.test_from_importcCsL|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr1z
import b as azimport b as a, c, a as f, d�
import a as fzimport b, c as f, d as erhr*rrr�test_import_as�sz Test_find_binding.test_import_ascCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)	Nr1�from x import b as a�from x import g as a, d as b�from x.b import t as a�from x.b import g as a, d�from a import b as tzfrom a.d import b as tzfrom d.a import b as trhr*rrr�test_from_import_as�sz%Test_find_binding.test_from_import_ascCsP|�|�dd��|�|�dd��|�|�ddd��|�|�ddd��dS)Nr2rWrXrNrhr*rrr�test_simple_import_with_package�sz1Test_find_binding.test_simple_import_with_packagecCs�|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd��|�|�dd	d��|�|�dd
d��|�|�ddd��|�|�ddd
��|�|�ddd
��|�|�ddd��dS)Nr1r\r[rZzfrom x import *r]r_r^zfrom x.b import *r`rSrUrTrVzfrom x.y import *r3rhr*rrr�test_from_import_with_package�sz/Test_find_binding.test_from_import_with_packagecCs@|�|�ddd��|�|�ddd��|�|�ddd��dS)Nr1zimport b.c as azb.crp�frlr*rrr�test_import_as_with_package�sz-Test_find_binding.test_import_as_with_packagecCs�|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd	��|�|�ddd
��dS)Nr1rrr[rsrtr^rurvr2�trlr*rrr� test_from_import_as_with_package�sz2Test_find_binding.test_from_import_as_with_packagecCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��d	}|�|�d|��dS)
Nr1z
def a(): passzdef a(b, c, d): passzdef a(): b = 7zdef d(b, (c, a), e): passzdef d(a=7): passzdef d(a): passzdef d(): a = 7zG
            def d():
                def a():
                    passrh�r�srrr�test_function_def�sz#Test_find_binding.test_function_defcCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd	��|�|�dd
��|�|�dd��d}|�|�d|��dS)
Nr1z
class a: passzclass a(): passzclass a(b): passzclass a(b, c=8): passz
class d: passzclass d(a): passzclass d(b, a=7): passzclass d(b, *a): passzclass d(b, **a): passzclass d: a = 7zK
            class d():
                class a():
                    passrhr~rrr�test_class_defsz Test_find_binding.test_class_defcCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)	Nr1zfor a in r: passzfor a, b in r: passzfor (a, b) in r: passzfor c, (a,) in r: passzfor c, (a, b) in r: passzfor c in r: a = czfor c in a: passrhr*rrr�test_forszTest_find_binding.test_forcCs�d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��d	}|�|�d|��dS)
NzM
            for b in r:
                for a in b:
                    passr1zP
            for b in r:
                for a, c in b:
                    passzR
            for b in r:
                for (a, c) in b:
                    passzP
            for b in r:
                for (a,) in b:
                    passzU
            for b in r:
                for c, (a, d) in b:
                    passzN
            for b in r:
                for c in b:
                    a = 7zN
            for b in r:
                for c in b:
                    d = azN
            for b in r:
                for c in a:
                    d = 7rhr~rrr�test_for_nested"s z!Test_find_binding.test_for_nestedcCs(|�|�dd��|�|�dd��dS)Nr1zif b in r: a = czif a in r: d = erhr*rrr�test_ifSszTest_find_binding.test_ifcCs0d}|�|�d|��d}|�|�d|��dS)NzL
            if b in r:
                if c in d:
                    a = cr1zL
            if b in r:
                if c in d:
                    c = arhr~rrr�test_if_nestedWsz Test_find_binding.test_if_nestedcCs(|�|�dd��|�|�dd��dS)Nr1zwhile b in r: a = czwhile a in r: d = erhr*rrr�
test_whiledszTest_find_binding.test_whilecCs0d}|�|�d|��d}|�|�d|��dS)NzR
            while b in r:
                while c in d:
                    a = cr1zR
            while b in r:
                while c in d:
                    c = arhr~rrr�test_while_nestedhsz#Test_find_binding.test_while_nestedcCs\d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��dS)NzQ
            try:
                a = 6
            except:
                b = 8r1zQ
            try:
                b = 8
            except:
                a = 6z�
            try:
                b = 8
            except KeyError:
                pass
            except:
                a = 6�Q
            try:
                b = 8
            except:
                b = 6rhr~rrr�test_try_exceptusz!Test_find_binding.test_try_exceptcCs�d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��dS)	Nz�
            try:
                try:
                    a = 6
                except:
                    pass
            except:
                b = 8r1z�
            try:
                b = 8
            except:
                try:
                    a = 6
                except:
                    passz�
            try:
                b = 8
            except:
                try:
                    pass
                except:
                    a = 6z�
            try:
                try:
                    b = 8
                except KeyError:
                    pass
                except:
                    a = 6
            except:
                passz�
            try:
                pass
            except:
                try:
                    b = 8
                except KeyError:
                    pass
                except:
                    a = 6r�a
            try:
                try:
                    b = 8
                except:
                    c = d
            except:
                try:
                    b = 6
                except:
                    t = 8
                except:
                    o = yrhr~rrr�test_try_except_nested�s


z(Test_find_binding.test_try_except_nestedcCs\d}|�|�d|��d}|�|�d|��d}|�|�d|��d}|�|�d|��dS)Nz|
            try:
                c = 6
            except:
                b = 8
            finally:
                a = 9r1zR
            try:
                b = 8
            finally:
                a = 6zR
            try:
                b = 8
            finally:
                b = 6z|
            try:
                b = 8
            except:
                b = 9
            finally:
                b = 6rhr~rrr�test_try_except_finally�sz)Test_find_binding.test_try_except_finallycCsFd}|�|�d|��d}|�|�d|��d}|�|�d|��dS)Nz�
            try:
                c = 6
            except:
                b = 8
            finally:
                try:
                    a = 9
                except:
                    b = 9
                finally:
                    c = 9r1z�
            try:
                b = 8
            finally:
                try:
                    pass
                finally:
                    a = 6z�
            try:
                b = 8
            finally:
                try:
                    b = 6
                finally:
                    b = 7rhr~rrr�test_try_except_finally_nestedsz0Test_find_binding.test_try_except_finally_nested)N)r r!r"rLrirjrkrmrnrorqrwrxryr{r}r�r�r�r�r�r�r�r�r�r�r�r�rrrrrg�s2

	
	1

M!rgc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�Test_touch_importcCs*td�}t�dd|�|�t|�d�dS)Nz"""foo"""
bar()�fooz"""foo"""
import foo
bar()

�rrZtouch_importrr�rrrrr�test_after_docstring'sz&Test_touch_import.test_after_docstringcCs*td�}t�dd|�|�t|�d�dS)Nz"""foo"""
import bar
bar()r�z'"""foo"""
import bar
import foo
bar()

r�r�rrr�test_after_imports,sz$Test_touch_import.test_after_importscCs*td�}t�dd|�|�t|�d�dS)N�bar()r�zimport foo
bar()

r�r�rrr�test_beginning1sz Test_touch_import.test_beginningcCs*td�}t�dd|�|�t|�d�dS)Nr�Zhtml�escapezfrom html import escape
bar()

r�r�rrrro6sz"Test_touch_import.test_from_importcCs*td�}t�dd|�|�t|�d�dS)Nr�Zcgizimport cgi
bar()

r�r�rrr�test_name_import;sz"Test_touch_import.test_name_importN)r r!r"r�r�r�ror�rrrrr�%s
r�c@seZdZdd�Zdd�ZdS)�Test_find_indentationcCs:tj}td�}|�||�d�td�}|�||�d�dS)Nznode()�)r�find_indentationrr�r�firrrr�test_nothingBs
z"Test_find_indentation.test_nothingcCsntj}td�}|�||�d�|�||jdjdjd�d�td�}|�||jdjdjd�d�dS)Nzdef f():
    x()r�rrDr%z    zdef f():
    x()
    y())rr�rrr
r�rrr�test_simpleIs"z!Test_find_indentation.test_simpleN)r r!r"r�r�rrrrr�@sr�N)r)r�rZlib2to3.pytreerrZlib2to3rZlib2to3.fixer_utilrrr	r
Z
lib2to3.pgen2rrZTestCaserr#r.r0r9r<rKrgr�r�rrrr�<module>s$
	,

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists