Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/list_tests.cpython-39.opt-2.pyc

a

XC?h5D�@sRddlZddlZddlmZddlmZmZddlmZm	Z	Gdd�dej
�Z
dS)�N)�
cmp_to_key)�support�	seq_tests)�	ALWAYS_EQ�NEVER_EQcs�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�|���|�gd��}|��|�||�g��|�gd��}|�gd��|�||�gd���|�|�}|�t|�t|��|�||�dS)N����)���)�assertEqual�	type2test�__init__ZassertNotEqual�id��self�a�b�r�4/opt/alt/python39/lib64/python3.9/test/list_tests.py�	test_inits
zCommonTest.test_initcCs@g}d}|�t|��|dWd�n1s20YdS)N�'list indices must be integers or slicesr��assertRaisesRegex�	TypeError�rr�msgrrr�test_getitem_error"szCommonTest.test_getitem_errorcCs@g}d}|�t|��d|d<Wd�n1s20YdS)Nr�pythonrrrrrr�test_setitem_error(szCommonTest.test_setitem_errorcCs�g}gd�}|�|�}|�|�}|�t|�t|��|�t|�t|��|�t|�t|��|�t|�d�|�t|�d�|�|�|�d�|�t|�d�|�t|�d�dS)N�rr	r
z	[0, 1, 2]rz[0, 1, 2, [...], 3])rr�str�repr�append)rZl0�l2Za0�a2rrr�	test_repr.s



zCommonTest.test_reprcCs>|�g�}tt��d�D]}|�|g�}q|�tt|�dS)N�d)r�range�sys�getrecursionlimit�assertRaises�RecursionErrorr%)rr�irrr�test_repr_deep?s
zCommonTest.test_repr_deepc	Cs�|�td��}|�|�|�tdd��|�|�|�d�z�ttjd��}|�t|��Wd�n1sn0Yttjd��$}|�	|�
�t|��Wd�n1s�0YWt�
tj�nt�
tj�0dS)N��i��w�r)rr+r&�extend�openrZTESTFN�writer$r�readr%�os�remove)r�dZforrr�
test_printEs


,4zCommonTest.test_printcCs�|�td��}|�t|jtddd�gd��|�t|jtdd�d�|�t|jtddd�ddg�|�t|jdd�gd�|tddd�<|�||�gd	���dS)
N�r�
rr	r
�xr)rr	r	rrr
r�r�	r>���
������)	rr+r.�
ValueError�__setitem__�slicer�__getitem__r�rrrrr�test_set_subscriptSszCommonTest.test_set_subscriptc	Csx|�td��}t|�}|�t|�|�tddd���|�tt|�|�tt|����|���|�tt	tgd���dS)Nr=rJ���r)
rr+�reversedr�listr.�
StopIteration�nextr�len)rrr4rrr�
test_reversed^s�zCommonTest.test_reversedcCs�|�ddg�}d|d<d|d<|�||�ddg��d|d<|�||�ddg��d|d<|�||�ddg��|�t|jdd�|�t|jdd�|�g�}|�t|jdd�|�t|jdd�|�t|j�|�gd	��}d|d<d|d<d
|d<|�||�gd���d|d<d
|d<d|d<|�||�gd���d|d<d|d<|�||�gd���d|d<d|d<|�||�gd���d}|�t|��d|d<Wd�n1�s�0YdS)Nrr	r*r2rQ������r
�rr	r
rrr)r	r
rrrr
rr@)r
rr@rr�X�c)r
rr@r[r\�rA)r
rr@r]rArr!r)rrr.�
IndexErrorrLrrrrrr�test_setitemhs@
zCommonTest.test_setitemcCs�|�ddg�}|d=|�|dg�|d=|�|g�|�ddg�}|d=|�|dg�|d=|�|g�|�ddg�}|�t|jd�|�t|jd�|�g�}|�t|jd�|�t|j�dS)Nrr	rXrQrYr
)rrr.r^�__delitem__rrOrrr�test_delitem�s 
zCommonTest.test_delitemcCsHddg}|�|�}tdd�D]�}|d|�|d|�<|�||�|dd�}|d|�|d|�<|�||�||d�||d�<|�||�|dd�}||d�||d�<|�||�tdd�D]P}|||�|||�<|�||�|dd�}|||�|||�<|�||�q�q|dd�}ddg|dd�<|�|gd��g|dd�<|�|g�|�gd��}||dd�<|�||�gd	���|�gd��}||dd�<|�||�gd
���|�gd��}||dd�<|�||�gd���|�g�}ttd��|dd�<|�||�td���|�t|jtddd
��|�t|j�dS)Nrr	rYrrXrQ)rXrQrr	)r	r
rrr
)r	r
rrr
r
)r	r	r
rrr
)r	r	r
rrr
r
r>r
)rr+r�tupler.rrLrM)r�lrr0r(�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)Nrr	r
rXrQ)rrrOrrr�
test_delslice�s>












zCommonTest.test_delslicecCsP|�g�}|�d�|�d�|�d�|�||�gd���|�t|j�dS)Nrr	r
r#)rr&rr.rrOrrr�test_append�s



zCommonTest.test_appendcCs�|�dg�}|�d�}|dd�}|�|�|�|||�|�|�g��|�|||�|�|�|�||�gd���|�d�}|�d�|�|td��|�t|jd�|�t|j�Gdd�d�}|�gd	��}|�|��|�|gd	��dS)
Nr)rr	)rrr	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�dSrk)rTrlrrr�__next__sz3CommonTest.test_extend.<locals>.CustomIter.__next__cSstjSrk)r,�maxsizerlrrr�__length_hint__sz:CommonTest.test_extend.<locals>.CustomIter.__length_hint__N)�__name__�
__module__�__qualname__rmrnrprrrr�
CustomItersrt)r	r
rr)rr5rrSr.r)rZa1r(rrtrrr�test_extends$




zCommonTest.test_extendcCs�|�gd��}|�dd�|�dd�|�dd�|�|gd��|dd�}|�dd�|�d	d
�|�dd�|�||�gd
���|�t|j�dS)Nr#rrXr	rQr
�rXrQrrr	r
�fooi8����leftr2�right)	rxrXrQrrrwr	r
ry)r�insertrr.rrrrr�test_insert$szCommonTest.test_insertcCs�|�gd��}|��|�|ddg�|�d�|�|dg�|�t|jd�|�d�|�|g�|�t|j�|�t|jdd�|�gd��}dS)N)rQrr	rQrr
�*)rr>r=��()r�poprr.r^rrOrrr�test_pop3s

zCommonTest.test_popcs&|�gd��}|�d�|�|ddg�|�d�|�|dg�|�d�|�|g�|�t|jd�|�t|j�|�ddg�}|�t|jt�|�|ddg�|�t�|�|dg�|�tg�}|�d�|�|g�|�tg�}|�t�|�|g�|�tg�}|�t|jt�Gdd�dt��G�fdd�d�}|�gd	��}|��|j|��G�fd
d�d�}|�d�}|�d
�|�||�d��|�d
�|�||�d��|�t|jd
�|�||�d��|�dd|�d
g�}|�|�}|��|jd
�t	||�D]\}}|�
||��q
dS)N)rrr	r	rr
c@seZdZdS)z&CommonTest.test_remove.<locals>.BadExcN)rqrrrsrrrr�BadExc[sr�cseZdZ�fdd�ZdS)z&CommonTest.test_remove.<locals>.BadCmpcs|dkr���dS)Nr
Fr�r�other�r�rr�__eq___sz-CommonTest.test_remove.<locals>.BadCmp.__eq__N�rqrrrsr�rr�rr�BadCmp^sr�)rr	r
rcseZdZ�fdd�ZdS)z'CommonTest.test_remove.<locals>.BadCmp2cs
���dSrkrr�r�rrr�hsz.CommonTest.test_remove.<locals>.BadCmp2.__eq__Nr�rr�rr�BadCmp2gsr�Zabcdefghcij�cZ
abdefghcijZ	abdefghijrr)rr:rr.rKrrr�	Exception�zip�assertIs)rrr�r�r;�er?�yrr�r�test_remove@sN









zCommonTest.test_removecs�t���|�gd�����d�|�t�jddd�|��|�gd���Gdd�d��|�����fdd	�td
�D��dd�<|�t�jd�dS)Nrvrr
r�rXrQrr	r
c@seZdZdd�Zdd�ZdS)z&CommonTest.test_index.<locals>.EvilCmpcSs
||_dSrk��victim)rr�rrrr�sz/CommonTest.test_index.<locals>.EvilCmp.__init__cSs|jdd�=dS)NFr�r�rrrr��sz-CommonTest.test_index.<locals>.EvilCmp.__eq__N)rqrrrsrr�rrrr�EvilCmp�sr�csg|]}����qSrr)�.0�_�r�rrr�
<listcomp>��z)CommonTest.test_index.<locals>.<listcomp>r*)	�super�
test_indexrr:r.rK�indexrr+rl��	__class__r�rr�{s

 zCommonTest.test_indexcCsZ|�gd��}|dd�}|��|�|gd��|��|�||�|�t|jd�dS)Nr��r
r	rrQrXr|)r�reverserr.r�r�uZu2rrr�test_reverse�szCommonTest.test_reversecCs�|�gd��}|��|�|g�|�g�}|��|�|g�|�g�}|�d�|��|�d�|�|dg�|�t|jd�dS)N)r
rrr	r
)r�clearrr&r.r�rr�rrr�
test_clear�s



zCommonTest.test_clearcCs�|�gd��}|��}|�|gd��|�g�}|��}|�|g�|�ddg�}|��}|�d�|�|ddg�|�||dg�|�ddddgd	g�}|��}|�||�|�|d|d�|�t|jd�dS)
Nrrrr0r	r
rrr
)r�copyrr&r�r.r)rr��vrrr�	test_copy�s 

zCommonTest.test_copycs|�ddg�}|��|�|ddg�|�gd��}|��|�||�gd���|�t|jdd�dd�}|jt|�d�|�||�gd���d	d
�}|�td����jt|�d�|�t�jd��fd
d�}|jt�jt|�d�|�t�jdddd�dS)Nr	rr�r�r|cSs ||krdS||krdSdSdS)Nrr	rQr)rrrrr�revcmp�s
z$CommonTest.test_sort.<locals>.revcmp)�keycSs2|d|d}}||krdS||kr*dSdSdS)Nrr@rrQr	r)r?r�ZxmodZymodrrr�myComparison�sz*CommonTest.test_sort.<locals>.myComparisonrCr
cs*��d�||krdS||kr"dSdSdS)Nr	rrQ)r&)r?r���zrr�selfmodifyingComparison�s
z5CommonTest.test_sort.<locals>.selfmodifyingComparison)r�sortrr.rrr+rK)rr�r�r�r�rr�r�	test_sort�s&
�zCommonTest.test_sortcCs*|�d�}d|dd�<|�|td��dS)Nrh�hr
Zham)rrrSr�rrr�
test_slice�s
zCommonTest.test_slicecslt���|�ddg�}|}|ddg7}|�||�|�d�}|d7}|�||�d��|�t|jd�dS)Nrr	r
rrhrirj)r��	test_iaddrr�rr.r�__iadd__r�r�rrr��s

zCommonTest.test_iaddcs8t���|�g�}t|�}|d9}|�t|�|�dS)Nr>)r��	test_imulrrr)r�sZoldidr�rrr�s


zCommonTest.test_imulcCs@|�gd��}|ddd�=|�||�ddg��|�td��}|ddd�=|�||�gd���|�td��}|ddd�=|�||�gd���|�td	��}|ddd
�=|�||�gd���|�td	��}dgd|ddd�<|�||�gd
���|�td	��}d	gd|ddd�<|�||�gd���|�td��}||ddd�<|�||�gd���|�td	��}|dd�}|dd�}|�ddg�|dd�<|�ddg�|tdd�<|�ddg�|dd�<|�||�|�||�|�td	��}ttd��|ddd�<|�||�gd���|�td	��}|dddd>�=dS)NrZr
r	rr
)rr
rrX)rr
rrr>i�)	r	r
rrr
rr@r]rArQ)
rQr	rQrrQr
rQr@rQrA���)
rr>r
rrr>rr@r]r>r)rr
r	rZtwo�elements)
rr	r	rr
r
rr@rrArAiM)rrr+rMrb)rrrr�rrr�test_extendedslicing
sDzCommonTest.test_extendedslicingcCs$Gdd�dt�}|�tt|��dS)Nc@seZdZdd�ZdS)z9CommonTest.test_constructor_exception_handling.<locals>.FcSst�dSrk)�KeyboardInterruptrlrrrrm6szBCommonTest.test_constructor_exception_handling.<locals>.F.__iter__N)rqrrrsrmrrrr�F5sr�)�objectr.r�rS)rr�rrr�#test_constructor_exception_handling3sz.CommonTest.test_constructor_exception_handlingcCsv|�gd��}t|�}t|�}|D]}t|�q"|�d�|�t|�g�|�t|�dg�|�||�gd���dS)NrrA)r	r
rrA)r�iterrUr&rrS)rrZexhitZempitr?rrr�test_exhausted_iterator:s

z"CommonTest.test_exhausted_iterator) rqrrrsrr r"r)r1r<rPrWr_rarerfrgrur{r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrr�rr
s8
%.)	!
;
0
)r)r,r9�	functoolsr�testrrZtest.supportrrrrrrr�<module>s