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_util.cpython-37.pyc
B

 ��g�R�@sdZddlmZddlmZmZddlmZddlm	Z	m
Z
mZmZddl
mZddd	�ZGd
d�dej�ZGdd
�d
ej�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZdS) z' Test suite for the code in fixer_util �)�support�)�Node�Leaf)�
fixer_util)�Attr�Name�Call�Comma)�tokencCs0t�|�}xt|�D]}|jd}qWd|_|S)Nr)rZparse_string�range�children�parent)�code�strip_levelsZtree�i�r�3/usr/local/lib/python3.7/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$)rrrr�test_invalid'szTest_is_tuple.test_invalidN)rr r!r$r&r(rrrrr"sr"c@s$eZdZdd�Zdd�Zdd�ZdS)�Test_is_listcCst�t|dd��S)Nr#)r)r�is_listr)rrrrrr*-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*)rrrrr&0s
zTest_is_list.test_validcCs|�|�d��dS)Nz[]+[])r'r*)rrrrr(7szTest_is_list.test_invalidN)rr r!r*r&r(rrrrr),sr)c@seZdZdd�Zdd�ZdS)�	Test_AttrcCs@tddd�}|�ttd�td��d�|�t|td��d�dS)Nzfoo()r#)r�a�bza.bzfoo().b)rrrr)rZcallrrr�test<szTest_Attr.testcCs&ttd�td��}|�t|�t�dS)Nr,r-)rrr�typer)r�attrrrr�test_returnsBszTest_Attr.test_returnsN)rr r!r.r1rrrrr+;sr+c@seZdZdd�ZdS)�	Test_NamecCs8|�td�d�|�td�d�|�tddd�d�dS)Nr,z
foo.foo().barr-)�prefixZba)rr)rrrrr.HszTest_Name.testN)rr r!r.rrrrr2Gsr2c@seZdZddd�Zdd�ZdS)�	Test_CallNcCsJg}t|t�r:x"|D]}|�|�|�t��qW|��tt|�||�S)zHelp the next test)rr�appendr
�popr	r)r�name�argsr3r
�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#��r-�j� )r3�AzA()zb(1,2,3)za.b().cza.b().c(1,3,2,4)�dz d(b, j))rr�NUMBER�STRINGrr:)rZkidsrrrr.YszTest_Call.test)NN)rr r!r:r.rrrrr4Ns

r4c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�Test_does_tree_importcCs<t�||�}|r|Sx"|jD]}|�||�}|r|SqWdS)N)r�find_bindingr
�_find_bind_rec)rr7r�cZchildrrrrEhsz$Test_does_tree_import._find_bind_reccCs"t|�}|�d|�}t�|||�S)N�start)rrEr�does_tree_import)r�packager7rrrrrrHqsz&Test_does_tree_import.does_tree_importcCs�d}xR|D]J\}}}|�|||d|�}|�|�|�|||d|�}|�|�q
Wd}xR|D]J\}}}|�|||d|�}|�|�|�|||d|�}|�|�qbWdS)N))r,r,zfrom a import b)za.dr,zfrom a.d import b)zd.ar,zfrom d.a import b)Nr,zimport b)Nr,zimport b, c, d�
))r,r,zfrom a import a)�xr,zfrom x import a)rKr,zfrom x import b, c, a, d)zx.br,zfrom x.b import a)zx.br,zfrom x.b import b, c, a, d)Nr,zimport a)Nr,zimport b, c, a, d)rHr'r%)rrZ
failing_testsrIr7�import_�nZ
passing_testsrrr�try_withws

zTest_does_tree_import.try_withcCs|�d�dS)Nzdef foo():
	bar.baz()
	start=3)rN)rrrr�test_in_function�sz&Test_does_tree_import.test_in_functionN)rr r!rErHrNrOrrrrrCgs	rCc@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|�|�S)N)rrDr)rr7rrIrrrrD�szTest_find_binding.find_bindingcCsp|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr,za = bz
a = [b, c, d]z	a = foo()za = foo().foo.foo[6][foo]zfoo = azfoo = (a, b, c))r%rDr')rrrr�test_simple_assignment�sz(Test_find_binding.test_simple_assignmentcCsp|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr,z(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))r%rDr')rrrr�test_tuple_assignment�sz'Test_find_binding.test_tuple_assignmentcCsp|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr,z[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))r%rDr')rrrr�test_list_assignment�sz&Test_find_binding.test_list_assignmentcCsL|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr,z	foo.a = 5z
foo[a] = 5z
foo(a) = 5z
foo(a, b) = 5)r'rD)rrrr�test_invalid_assignments�sz*Test_find_binding.test_invalid_assignmentscCsL|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr,zimport azimport b, c, a, dzimport bzimport b, c, d)r%rDr')rrrr�test_simple_import�sz$Test_find_binding.test_simple_importcCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd	��dS)
Nr,zfrom x import azfrom a import azfrom x import b, c, a, dzfrom x.b import azfrom x.b import b, c, a, dzfrom a import bzfrom a.d import bzfrom d.a import b)r%rDr')rrrr�test_from_import�sz"Test_find_binding.test_from_importcCsL|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr,z
import b as azimport b as a, c, a as f, dz
import a as fzimport b, c as f, d as e)r%rDr')rrrr�test_import_as�sz Test_find_binding.test_import_ascCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)	Nr,zfrom x import b as azfrom x import g as a, d as bzfrom x.b import t as azfrom x.b import g as a, dzfrom a import b as tzfrom a.d import b as tzfrom d.a import b as t)r%rDr')rrrr�test_from_import_as�sz%Test_find_binding.test_from_import_ascCsP|�|�dd��|�|�dd��|�|�ddd��|�|�ddd��dS)Nr-zimport bzimport b, c, drF)r%rDr')rrrr�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)Nr,zfrom x import arKzfrom a import azfrom x import *zfrom x import b, c, a, dzfrom x.b import azx.bzfrom x.b import *zfrom x.b import b, c, a, dzfrom a import bzfrom a.d import bza.dzfrom d.a import bzfrom x.y import *za.b)r%rDr')rrrr�test_from_import_with_package�sz/Test_find_binding.test_from_import_with_packagecCs@|�|�ddd��|�|�ddd��|�|�ddd��dS)Nr,zimport b.c as azb.cz
import a as f�f)r'rD)rrrr�test_import_as_with_package�sz-Test_find_binding.test_import_as_with_packagecCs�|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd	��|�|�ddd
��dS)Nr,zfrom x import b as arKzfrom x import g as a, d as bzfrom x.b import t as azx.bzfrom x.b import g as a, dzfrom a import b as tr-�t)r'rD)rrrr� 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)
Nr,z
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():
                    pass)r%rDr')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)
Nr,z
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():
                    pass)r%rDr')rr_rrr�test_class_defsz Test_find_binding.test_class_defcCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)	Nr,zfor 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: pass)r%rDr')rrrr�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:
                    passr,zP
            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 = 7)r%rDr')rr_rrr�test_for_nested"s z!Test_find_binding.test_for_nestedcCs(|�|�dd��|�|�dd��dS)Nr,zif b in r: a = czif a in r: d = e)r%rDr')rrrr�test_ifSszTest_find_binding.test_ifcCs0d}|�|�d|��d}|�|�d|��dS)NzL
            if b in r:
                if c in d:
                    a = cr,zL
            if b in r:
                if c in d:
                    c = a)r%rDr')rr_rrr�test_if_nestedWsz Test_find_binding.test_if_nestedcCs(|�|�dd��|�|�dd��dS)Nr,zwhile b in r: a = czwhile a in r: d = e)r%rDr')rrrr�
test_whiledszTest_find_binding.test_whilecCs0d}|�|�d|��d}|�|�d|��dS)NzR
            while b in r:
                while c in d:
                    a = cr,zR
            while b in r:
                while c in d:
                    c = a)r%rDr')rr_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 = 8r,zQ
            try:
                b = 8
            except:
                a = 6z�
            try:
                b = 8
            except KeyError:
                pass
            except:
                a = 6zQ
            try:
                b = 8
            except:
                b = 6)r%rDr')rr_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 = 8r,z�
            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 = 6zQ
            try:
                b = 8
            except:
                b = 6a
            try:
                try:
                    b = 8
                except:
                    c = d
            except:
                try:
                    b = 6
                except:
                    t = 8
                except:
                    o = y)r%rDr')rr_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 = 9r,zR
            try:
                b = 8
            finally:
                a = 6zR
            try:
                b = 8
            finally:
                b = 6z|
            try:
                b = 8
            except:
                b = 9
            finally:
                b = 6)r%rDr')rr_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 = 9r,z�
            try:
                b = 8
            finally:
                try:
                    pass
                finally:
                    a = 6z�
            try:
                b = 8
            finally:
                try:
                    b = 6
                finally:
                    b = 7)r%rDr')rr_rrr�test_try_except_finally_nesteds		z0Test_find_binding.test_try_except_finally_nested)N)rr r!rDrQrRrSrTrUrVrWrXrYrZr\r^r`rarbrcrdrerfrgrhrirjrkrrrrrP�s2

	
	1

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

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

)rrrnrr)rrrrr�test_after_imports,sz$Test_touch_import.test_after_importscCs*td�}t�dd|�|�t|�d�dS)Nzbar()rmzimport foo
bar()

)rrrnrr)rrrrr�test_beginning1sz Test_touch_import.test_beginningcCs*td�}t�dd|�|�t|�d�dS)Nzbar()Zhtml�escapezfrom html import escape
bar()

)rrrnrr)rrrrrrV6sz"Test_touch_import.test_from_importcCs*td�}t�dd|�|�t|�d�dS)Nzbar()Zcgizimport cgi
bar()

)rrrnrr)rrrrr�test_name_import;sz"Test_touch_import.test_name_importN)rr r!rorprqrVrsrrrrrl%s
rlc@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()rurr<r#z    zdef f():
    x()
    y())rrvrrr
)rrwrrrr�test_simpleIs"z!Test_find_indentation.test_simpleN)rr r!rxryrrrrrt@srtN)r)�__doc__rurZlib2to3.pytreerrZlib2to3rZlib2to3.fixer_utilrrr	r
Z
lib2to3.pgen2rrZTestCaserr"r)r+r2r4rCrPrlrtrrrr�<module>s&
	,