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_util.cpython-310.opt-1.pyc
o

�i�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)�tokencCs,t�|�}t|�D]}|jd}q	d|_|S)Nr)rZparse_string�range�children�parent)�code�strip_levelsZtree�i�r�4/usr/local/lib/python3.10/lib2to3/tests/test_util.py�parses

rc@�eZdZdd�ZdS)�
MacroTestCasecCs0t|ttf�rttjj|�}|�t|�|�dS�N)	�
isinstance�tuple�listrrZsymsZsimple_stmt�assertEqual�str)�self�node�stringrrr�	assertStrszMacroTestCase.assertStrN)�__name__�
__module__�__qualname__r rrrrr�rc@�$eZdZdd�Zdd�Zdd�ZdS)�
Test_is_tuplecC�t�t|dd��S�N��r)r�is_tupler�rrrrrr+�zTest_is_tuple.is_tuplecC�T|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��dS)Nz(a, b)z(a, (b, c))z((a, (b, c)),)z(a,)z())�
assertTruer+�rrrr�
test_valid �
zTest_is_tuple.test_validcCs$|�|�d��|�|�d��dS)Nz(a)z('foo') % (b, c))�assertFalser+r0rrr�test_invalid'szTest_is_tuple.test_invalidN)r!r"r#r+r1r4rrrrr&�r&c@r%)�Test_is_listcCr'r()r�is_listrr,rrrr7-r-zTest_is_list.is_listcCr.)Nz[]z[a]z[a, b]z[a, [b, c]]z[[a, [b, c]],])r/r7r0rrrr10r2zTest_is_list.test_validcCs|�|�d��dS)Nz[]+[])r3r7r0rrrr47szTest_is_list.test_invalidN)r!r"r#r7r1r4rrrrr6,r5r6c@�eZdZdd�Zdd�ZdS)�	Test_AttrcCs@tddd�}|�ttd�td��d�|�t|td��d�dS)Nzfoo()r)r*�a�b�a.bzfoo().b)rr rr)r�callrrr�test<szTest_Attr.testcCs&ttd�td��}|�t|�t�dS)Nr:r;)rrr�typer)r�attrrrr�test_returnsBszTest_Attr.test_returnsN)r!r"r#r>rArrrrr9;sr9c@r)�	Test_NamecCs8|�td�d�|�td�d�|�tddd�d�dS)Nr:z
foo.foo().barr;��prefixZba)r rr0rrrr>HszTest_Name.testN)r!r"r#r>rrrrrBGr$rBc@seZdZddd�Zdd�ZdS)�	Test_CallNcCsFg}t|t�r|D]
}|�|�|�t��q	|��tt|�||�S)zHelp the next test)rr�appendr
�popr	r)r�name�argsrDr
�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� rC�AzA()zb(1,2,3)za.b().cza.b().c(1,3,2,4)�dz d(b, j))rr�NUMBER�STRINGr rK)rZkidsrrrr>Ys
��� zTest_Call.test)NN)r!r"r#rKr>rrrrrENs

rEc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�Test_does_tree_importcCs<t�||�}|r
|S|jD]}|�||�}|r|Sq
dSr)r�find_bindingr
�_find_bind_rec)rrHr�c�childrrrrVhs
�z$Test_does_tree_import._find_bind_reccCs"t|�}|�d|�}t�|||�S)N�start)rrVr�does_tree_import)r�packagerHrrrrrrZqsz&Test_does_tree_import.does_tree_importcCs�d}|D]%\}}}|�|||d|�}|�|�|�|||d|�}|�|�qd}|D]%\}}}|�|||d|�}|�|�|�|||d|�}|�|�q.dS)N))r:r:�from a import b)�a.dr:�from a.d import b)zd.ar:�from d.a import b)Nr:�import b)Nr:�import b, c, d�
))r:r:�from a import a)�xr:�from x import a)rdr:�from x import b, c, a, d)�x.br:�from x.b import a)rgr:�from x.b import b, c, a, d)Nr:�import a)Nr:�import b, c, a, d)rZr3r/)rrZ
failing_testsr[rH�import_�nZ
passing_testsrrr�try_withws

�zTest_does_tree_import.try_withcCs|�d�dS)Nzdef foo():
	bar.baz()
	start=3)rnr0rrr�test_in_function�sz&Test_does_tree_import.test_in_functionN)r!r"r#rVrZrnrorrrrrTgs
	rTc@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)rrUr)rrHrr[rrrrU�r-zTest_find_binding.find_bindingcC�p|�|�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/rUr3r0rrr�test_simple_assignment��z(Test_find_binding.test_simple_assignmentcCrq)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)rrr0rrr�test_tuple_assignment�rtz'Test_find_binding.test_tuple_assignmentcCrq)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)rrr0rrr�test_list_assignment�rtz&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�r3rUr0rrr�test_invalid_assignments��z*Test_find_binding.test_invalid_assignmentscC�L|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)Nr:rjrkr`rarrr0rrr�test_simple_import�ryz$Test_find_binding.test_simple_importcCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd	��dS)
Nr:rercrfrhrir\r^r_rrr0rrr�test_from_import�sz"Test_find_binding.test_from_importcCrz)Nr:z
import b as azimport b as a, c, a as f, d�
import a as fzimport b, c as f, d as errr0rrr�test_import_as�ryz Test_find_binding.test_import_ascCs�|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|�dd��dS)	Nr:�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 trrr0rrr�test_from_import_as��z%Test_find_binding.test_from_import_ascCsP|�|�dd��|�|�dd��|�|�ddd��|�|�ddd��dS)Nr;r`rarWrrr0rrr�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:rerdrczfrom x import *rfrhrgzfrom x.b import *rir\r^r]r_zfrom x.y import *r<rrr0rrr�test_from_import_with_package�sz/Test_find_binding.test_from_import_with_packagecCs@|�|�ddd��|�|�ddd��|�|�ddd��dS)Nr:zimport b.c as azb.cr}�frwr0rrr�test_import_as_with_package�sz-Test_find_binding.test_import_as_with_packagecCs�|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd��|�|�ddd	��|�|�ddd
��dS)Nr:rrdr�r�rgr�r�r;�trwr0rrr� 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():
                    passrr�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():
                    passrrr�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: passrrr0rrr�test_forr�zTest_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 = 7rrr�rrr�test_for_nested"s z!Test_find_binding.test_for_nestedcC�(|�|�dd��|�|�dd��dS)Nr:zif b in r: a = czif a in r: d = errr0rrr�test_ifS�zTest_find_binding.test_ifcC�0d}|�|�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 = arrr�rrr�test_if_nestedW�z Test_find_binding.test_if_nestedcCr�)Nr:zwhile b in r: a = czwhile a in r: d = errr0rrr�
test_whiledr�zTest_find_binding.test_whilecCr�)NzR
            while b in r:
                while c in d:
                    a = cr:zR
            while b in r:
                while c in d:
                    c = arrr�rrr�test_while_nestedhr�z#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 = 6�Q
            try:
                b = 8
            except:
                b = 6rrr�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 = 6r�a
            try:
                try:
                    b = 8
                except:
                    c = d
            except:
                try:
                    b = 6
                except:
                    t = 8
                except:
                    o = yrrr�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 = 6rrr�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 = 7rrr�rrr�test_try_except_finally_nestedsz0Test_find_binding.test_try_except_finally_nestedr)r!r"r#rUrsrurvrxr{r|r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrp�s4

	
	1

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

�rrZtouch_importrr�rrrrr�test_after_docstring'�z&Test_touch_import.test_after_docstringcCr�)Nz"""foo"""
import bar
bar()r�z'"""foo"""
import bar
import foo
bar()

r�r�rrr�test_after_imports,r�z$Test_touch_import.test_after_importscCr�)N�bar()r�zimport foo
bar()

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

r�r�rrrr|6r�z"Test_touch_import.test_from_importcCr�)Nr�Zcgizimport cgi
bar()

r�r�rrr�test_name_import;r�z"Test_touch_import.test_name_importN)r!r"r#r�r�r�r|r�rrrrr�%sr�c@r8)�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�rrMr)z    zdef f():
    x()
    y())rr�rrr
r�rrr�test_simpleIs"&z!Test_find_indentation.test_simpleN)r!r"r#r�r�rrrrr�@sr�N)r)�__doc__r�rZlib2to3.pytreerrZlib2to3rZlib2to3.fixer_utilrrr	r
Z
lib2to3.pgen2rrZTestCaserr&r6r9rBrErTrpr�r�rrrr�<module>s(
	,