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/test/__pycache__/list_tests.cpython-37.pyc
B

��g(B�@sFdZddlZddlZddlmZddlmZmZGdd�dej�ZdS)z,
Tests common to list and UserList.UserList
�N)�
cmp_to_key)�support�	seq_testscs�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Z�fd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Z�fd/d0�Z�fd1d2�Zd3d4�Zd5d6�Zd7d8�Z�ZS)9�
CommonTestcCs�|�|�g�|���|�dddg�}|��|�||�g��|�dddg�}|�dddg�|�||�dddg��|�|�}|�t|�t|��|�||�dS)N������)�assertEqual�	type2test�__init__ZassertNotEqual�id)�self�a�b�r�+/usr/local/lib/python3.7/test/list_tests.py�	test_inits
zCommonTest.test_initc	Cs,g}d}|�t|��|dWdQRXdS)Nz'list indices must be integers or slicesr)�assertRaisesRegex�	TypeError)rr�msgrrr�test_getitem_error!szCommonTest.test_getitem_errorc	Cs,g}d}|�t|��d|d<WdQRXdS)Nz'list indices must be integers or slices�pythonr)rr)rrrrrr�test_setitem_error'szCommonTest.test_setitem_errorcCs�g}dddg}|�|�}|�|�}|�t|�t|��|�t|�t|��|�t|�t|��|�t|�d�|�t|�d�|�|�|�d�|�t|�d�|�t|�d�dS)Nrrrz	[0, 1, 2]rz[0, 1, 2, [...], 3])r
r�str�repr�append)rZl0�l2Za0�a2rrr�	test_repr-s




zCommonTest.test_reprcCsB|�g�}x$tt��d�D]}|�|g�}qW|�tt|�dS)N�d)r
�range�sys�getrecursionlimit�assertRaises�RecursionErrorr)rr�irrr�test_repr_deep>s
zCommonTest.test_repr_deepc	Cs�|�td��}|�|�|�tdd��|�|�|�d�zVttjd��}|�t|��WdQRXttjd��}|�	|�
�t|��WdQRXWdt�
tj�XdS)N��i��w�r)r
r#r�extend�openrZTESTFN�writerr�readr�os�remove)r�d�forrr�
test_printDs


"zCommonTest.test_printcCs�|�td��}|�t|jtddd�dddg�|�t|jtdd�d�|�t|jtddd�ddg�|�t|jdd�dddg|tddd�<|�||�ddddddd	d
ddddd
dddddddg��dS)N�r�
rrr�xr	r��	���
������)	r
r#r&�
ValueError�__setitem__�slicer�__getitem__r)rrrrr�test_set_subscriptRs zCommonTest.test_set_subscriptc	Csz|�td��}t|�}|�t|�|�tddd���|�tt|�|�tt|����|���|�tt	tdddg��dS)Nr6rC���rrr)
r
r#�reversedr�listr&�
StopIteration�nextr�len)rrr,rrr�
test_reversed]s
zCommonTest.test_reversedc
Cs�|�ddg�}d|d<d|d<|�||�ddg��d|d<|�||�ddg��d|d<|�||�ddg��|�t|jdd�|�t|jdd�|�g�}|�t|jdd�|�t|jdd�|�t|j�|�dddd	d
g�}d|d<d|d<d	|d<|�||�ddd	d	d
g��d|d<d|d<d
|d<|�||�ddd
d	d
g��d|d<d|d<|�||�ddd
ddg��d|d<d|d<|�||�ddd
ddg��d}|�t|��d|d<WdQRXdS)Nrrr"r*rI������rrr	r
rr9�X�c�r:z'list indices must be integers or slicesrr)r
rr&�
IndexErrorrErr)rrrrrr�test_setitemgs@
zCommonTest.test_setitemcCs�|�ddg�}|d=|�|dg�|d=|�|g�|�ddg�}|d=|�|dg�|d=|�|g�|�ddg�}|�t|jd�|�t|jd�|�g�}|�t|jd�|�t|j�dS)NrrrPrIrQr)r
rr&rU�__delitem__r)rrrrr�test_delitem�s 
zCommonTest.test_delitemcCs�ddg}|�|�}�x
tdd�D]�}|d|�|d|�<|�||�|dd�}|d|�|d|�<|�||�||d�||d�<|�||�|dd�}||d�||d�<|�||�x^tdd�D]P}|||�|||�<|�||�|dd�}|||�|||�<|�||�q�Wq W|dd�}ddg|dd�<|�|ddddg�g|dd�<|�|g�|�ddddd	g�}||dd�<|�||�ddddd	d	g��|�ddddd	g�}||dd�<|�||�dddddd	g��|�ddddd	g�}||dd�<|�||�dddddd	d	g��|�g�}ttd
��|dd�<|�||�td
���|�t|jtddd	��|�t|j�dS)NrrrQr	rPrIrrr
r7)r
r#r�tupler&rrErF)r�lrr(r �jZaa2rrr�
test_setslice�sL
 
zCommonTest.test_setslicecCs�|�ddg�}|dd�=|dd�=|�||�g��|�ddg�}|dd�=|dd�=|�||�g��|�ddg�}|dd�=|�||�dg��|�ddg�}|dd�=|�||�dg��|�ddg�}|dd�=|dd�=|�||�g��|�ddg�}|dd�=|dd�=|�||�g��|�ddg�}|dd�=|�||�dg��|�ddg�}|dd�=|�||�dg��|�ddg�}|dd�=|�||�g��dS)NrrrrPrI)r
r)rrrrr�
test_delslice�s>












zCommonTest.test_delslicecCsR|�g�}|�d�|�d�|�d�|�||�dddg��|�t|j�dS)Nrrr)r
rrr&r)rrrrr�test_append�s



zCommonTest.test_appendcCs
|�dg�}|�d�}|dd�}|�|�|�|||�|�|�g��|�|||�|�|�|�||�ddddddg��|�d�}|�d�|�|td��|�t|jd�|�t|j�Gdd�d�}|�dd	d
dg�}|�|��|�|dd	d
dg�dS)Nr)rrr�spam�eggs�spameggsc@s$eZdZdd�Zdd�Zdd�ZdS)z*CommonTest.test_extend.<locals>.CustomItercSs|S)Nr)rrrr�__iter__sz3CommonTest.test_extend.<locals>.CustomIter.__iter__cSst�dS)N)rL)rrrr�__next__sz3CommonTest.test_extend.<locals>.CustomIter.__next__cSstjS)N)r$�maxsize)rrrr�__length_hint__sz:CommonTest.test_extend.<locals>.CustomIter.__length_hint__N)�__name__�
__module__�__qualname__rbrcrerrrr�
CustomItersrirrr	)r
r-rrKr&r)rZa1r rrirrr�test_extends$




zCommonTest.test_extendcCs�|�dddg�}|�dd�|�dd�|�dd�|�|ddddddg�|dd�}|�dd�|�dd�|�d	d
�|�||�ddddddddd
g	��|�t|j�dS)NrrrrPrIZfooi8����leftr*�right)r
�insertrr&r)rrrrrr�test_insert#s$zCommonTest.test_insertcCs�|�dddg�}|��|�|ddg�|�d�|�|dg�|�t|jd�|�d�|�|g�|�t|j�|�t|jdd�|�ddddd	g�}dS)
NrIrrr
�*r7r6��()r
�poprr&rUr)rrrrr�test_pop2s

zCommonTest.test_popcs�|�dddg�}|�d�|�|ddg�|�d�|�|dg�|�d�|�|g�|�t|jd�|�t|j�Gdd�dt��G�fdd�d�}|�ddddg�}|��|j|��G�fd	d
�d
�}|�d�}|�d�|�||�d
��|�d�|�||�d��|�t|jd�|�||�d��|�dd|�dg�}|�|�}|��|jd�x$t||�D]\}}|�||��qlWdS)Nrrc@seZdZdS)z&CommonTest.test_remove.<locals>.BadExcN)rfrgrhrrrr�BadExcLsrtcseZdZ�fdd�ZdS)z&CommonTest.test_remove.<locals>.BadCmpcs|dkr���dS)NrFr)r�other)rtrr�__eq__Psz-CommonTest.test_remove.<locals>.BadCmp.__eq__N)rfrgrhrvr)rtrr�BadCmpOsrwrrcseZdZ�fdd�ZdS)z'CommonTest.test_remove.<locals>.BadCmp2cs
���dS)Nr)rru)rtrrrvYsz.CommonTest.test_remove.<locals>.BadCmp2.__eq__N)rfrgrhrvr)rtrr�BadCmp2XsrxZabcdefghcij�cZ
abdefghcijZ	abdefghijrr)	r
r2rr&rDr�	Exception�zip�assertIs)rrrwrxr3�er8�yr)rtr�test_remove?s4






zCommonTest.test_removec
s�t���|�ddddddg����d�|�t�jddd�|��|�dddddg��Gdd�d��|�����fd	d
�td�D��dd�<|�t�jd�dS)NrPrIrrrr	c@seZdZdd�Zdd�ZdS)z&CommonTest.test_index.<locals>.EvilCmpcSs
||_dS)N)�victim)rr�rrrrusz/CommonTest.test_index.<locals>.EvilCmp.__init__cSs|jdd�=dS)NF)r�)rrurrrrvwsz-CommonTest.test_index.<locals>.EvilCmp.__eq__N)rfrgrhrrvrrrr�EvilCmptsr�csg|]}����qSrr)�.0�_)r�rrr�
<listcomp>{sz)CommonTest.test_index.<locals>.<listcomp>r")	�super�
test_indexr
r2r&rD�indexrr#)r)�	__class__)r�rrr�ls

 zCommonTest.test_indexcCsf|�dddddg�}|dd�}|��|�|dddddg�|��|�||�|�t|jd�dS)NrPrIrrrro)r
�reverserr&r)r�u�u2rrr�test_reverseszCommonTest.test_reversecCs�|�dddg�}|��|�|g�|�g�}|��|�|g�|�g�}|�d�|��|�d�|�|dg�|�t|jd�dS)Nrrr	r)r
�clearrrr&r)rr�rrr�
test_clear�s



zCommonTest.test_clearcCs�|�dddg�}|��}|�|dddg�|�g�}|��}|�|g�|�ddg�}|��}|�d�|�|ddg�|�||dg�|�ddddgdg�}|��}|�||�|�|d|d�|�t|jd�dS)	Nrrrrrr(r	r
)r
�copyrrr|r&r)rr��vrrr�	test_copy�s 

zCommonTest.test_copyc
s|�ddg�}|��|�|ddg�|�dddddg�}|��|�||�dddddg��|�t|jdd�dd�}|jt|�d	�|�||�dddddg��d
d�}|�td����jt|�d	�|�t�jd��fd
d�}|jt�jt|�d	�|�t�jdddd�dS)NrrrrIrProcSs ||krdS||krdSdSdS)NrrrIr)rrrrr�revcmp�s
z$CommonTest.test_sort.<locals>.revcmp)�keycSs2|d|d}}||krdS||kr*dSdSdS)Nrr9rrIrr)r8r~ZxmodZymodrrr�myComparison�sz*CommonTest.test_sort.<locals>.myComparisonr<cs*��d�||krdS||kr"dSdSdS)NrrrI)r)r8r~)�zrr�selfmodifyingComparison�s
z5CommonTest.test_sort.<locals>.selfmodifyingComparison)r
�sortrr&rrr#rD)rr�r�r�r�r)r�r�	test_sort�s$
zCommonTest.test_sortcCs*|�d�}d|dd�<|�|td��dS)Nr_�hrZham)r
rrK)rr�rrr�
test_slice�s
zCommonTest.test_slicecslt���|�ddg�}|}|ddg7}|�||�|�d�}|d7}|�||�d��|�t|jd�dS)Nrrrrr_r`ra)r��	test_iaddr
r|rr&r�__iadd__)rr�r�)r�rrr��s

zCommonTest.test_iaddcs8t���|�g�}t|�}|d9}|�t|�|�dS)Nr7)r��	test_imulr
rr)r�sZoldid)r�rrr��s


zCommonTest.test_imulcCs�|�dddddg�}|ddd�=|�||�ddg��|�td��}|ddd�=|�||�dddg��|�td��}|ddd�=|�||�ddddg��|�td��}|ddd	�=|�||�dddddd
ddd
g	��|�td��}dgd|ddd�<|�||�dddddddddd
g
��|�td��}dgd|ddd�<|�||�ddddddd
dddg
��|�td��}||ddd�<|�||�ddddg��|�td��}|dd�}|dd�}|�ddg�|dd�<|�ddg�|tdd�<|�ddg�|dd�<|�||�|�||�|�td��}ttd��|ddd�<|�||�dddddddddd
g
��|�td��}|d
ddd>�=dS)Nrrrrr	r
rPr7i�rr9rTr:rI���Ztwo�elementsiM)r
rr#rFrY)rrrryrrr�test_extendedslicing�sD$&&&zCommonTest.test_extendedslicingcCs$Gdd�dt�}|�tt|��dS)Nc@seZdZdd�ZdS)z9CommonTest.test_constructor_exception_handling.<locals>.FcSst�dS)N)�KeyboardInterrupt)rrrrrb'szBCommonTest.test_constructor_exception_handling.<locals>.F.__iter__N)rfrgrhrbrrrr�F&sr�)�objectr&r�rK)rr�rrr�#test_constructor_exception_handling$sz.CommonTest.test_constructor_exception_handlingc	Cs�|�dddg�}t|�}t|�}x|D]}t|�q&W|�d�|�t|�g�|�t|�dg�|�||�ddddg��dS)Nrrrr:)r
�iterrMrrrK)rrZexhitZempitr8rrr�test_exhausted_iterator+s

z"CommonTest.test_exhausted_iterator) rfrgrhrrrr!r)r5rHrOrVrXr\r]r^rjrnrsrr�r�r�r�r�r�r�r�r�r�r��
__classcell__rr)r�rrs8
%.)	!
-
0
)r)	�__doc__r$r1�	functoolsrZtestrrrrrrr�<module>s