Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/list_tests.cpython-35.opt-1.pyc



��Yf�G�@sadZddlZddlZddlmZddlmZmZGdd�dej�ZdS)z,
Tests common to list and UserList.UserList
�N)�
cmp_to_key)�support�	seq_testscsZeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Z�fd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Z�S)7�
CommonTestcCs�|j|jg�|j��|jdddg�}|j�|j||jg��|jdddg�}|jdddg�|j||jdddg��|j|�}|jt|�t|��|j||�dS)N������)�assertEqual�	type2test�__init__ZassertNotEqual�id)�self�a�b�r�4/opt/alt/python35/lib64/python3.5/test/list_tests.py�	test_inits
"zCommonTest.test_initc
Cs4d}|jt|��g}d|d<WdQRXdS)Nz'list indices must be integers or slices�pythonr)�assertRaisesRegex�	TypeError)r�msgrrrr�test_getitem_error!szCommonTest.test_getitem_errorcCs@g}dddg}|j|�}|j|�}|jt|�t|��|jt|�t|��|jt|�t|��|jt|�d�|jt|�d�|j|�|jd�|jt|�d�|jt|�d�g}x'ttj�d�D]}|g}qW|jt	t|�dS)Nrrrz	[0, 1, 2]rz[0, 1, 2, [...], 3]�d)
r
r�str�repr�append�range�sys�getrecursionlimit�assertRaises�RecursionError)rZl0�l2Za0�a2�irrr�	test_repr's"


zCommonTest.test_reprcCs�|jtd��}|j|�|jtdd��|j|�|jd�zkttjd��}|jt|��WdQRXttjd��#}|j	|j
�t|��WdQRXWdtj
tj�XdS)N��i��w�r)r
rr�extend�openrZTESTFN�writerr�readr�os�remove)r�dZforrr�
test_print=s


'zCommonTest.test_printcCs!|jtd��}|jt|jtddd�dddg�|jt|jtdd�d�|jt|jtddd�ddg�|jt|jdd�dddg|tddd�<|j||jddddddd	d
ddddd
dddddddg��dS)N�r�
rrr�xr	r��	���
������)	r
rr"�
ValueError�__setitem__�slicer�__getitem__r)rrrrr�test_set_subscriptKs."+*zCommonTest.test_set_subscriptcCs�|jtd��}t|�}|jt|�|jtddd���|jtt|�|jtt|j���|j��|jtt	tdddg��dS)Nr3r@rrr���rF)
r
r�reversedr�listr"�
StopIteration�nextr�len)rrr*rrr�
test_reversedVs+
zCommonTest.test_reversedc
Csp|jddg�}d|d<d|d<|j||jddg��d|d<|j||jddg��d|d<|j||jddg��|jt|jdd�|jt|jdd�|jg�}|jt|jdd�|jt|jdd�|jt|j�|jdddddg�}d|d<d|d<d|d<|j||jdddddg��d|d<d	|d<d
|d<|j||jdd	d
ddg��d|d<d|d<|j||jdd	d
ddg��d
|d<d|d<|j||jdd	d
d
dg��d}|jt|��d|d<WdQRXdS)Nrrrr(rrr	r
rr6�X�c�r7z'list indices must be integers or slicesrrrF������rFrPrFrPrF)r
rr"�
IndexErrorrBrr)rrrrrr�test_setitem`s@






(


(

(

(zCommonTest.test_setitemcCs	|jddg�}|d=|j|dg�|d=|j|g�|jddg�}|d=|j|dg�|d=|j|g�|jddg�}|jt|jd�|jt|jd�|jg�}|jt|jd�|jt|j�dS)NrrrrrPrFrQ)r
rr"rR�__delitem__r)rrrrr�test_delitem�s zCommonTest.test_delitemc
Csnddg}|j|�}x]tdd�D]L}|d|�|d|�<|j||�|dd�}|d|�|d|�<|j||�||d�||d�<|j||�|dd�}||d�||d�<|j||�x{td	d�D]j}|||�|||�<|j||�|dd�}|||�|||�<|j||�q	Wq+W|dd�}d
dg|dd�<|j|dd
ddg�g|dd�<|j|g�|jdddddg�}||dd�<|j||jddddddg��|jdddddg�}||dd�<|j||jddddddg��|jdddddg�}||dd�<|j||jdddddddg��|jg�}ttd��|dd�<|j||jtd���|jt|jtddd��|jt|j�dS)Nrrrr	rr
r4rQrQrPrFrPrFrFrF)r
rr�tupler"rrBrC)r�lrr&r%�jZaa2rrr�
test_setslice�sL++."zCommonTest.test_setslicecCsW|jddg�}|dd�=|dd�=|j||jg��|jddg�}|dd�=|dd�=|j||jg��|jddg�}|dd�=|j||jdg��|jddg�}|dd�=|j||jdg��|jddg�}|dd�=|dd�=|j||jg��|jddg�}|dd�=|dd�=|j||jg��|jddg�}|dd�=|j||jdg��|jddg�}|d	d�=|j||jdg��|jddg�}|dd�=|j||jg��dS)
NrrrrPrFrPrFrFrF)r
r)rrrrr�
test_delslice�s>












zCommonTest.test_delslicecCso|jg�}|jd�|jd�|jd�|j||jdddg��|jt|j�dS)Nrrr)r
rrr"r)rrrrr�test_append�s


"zCommonTest.test_appendc	Cs|jdg�}|jd�}|dd�}|j|�|j|||�|j|jg��|j|||�|j|�|j||jddddddg��|jd�}|jd�|j|td��|jt|jd�|jt|j�dS)Nrr�spam�eggs�spameggs)rr)r
r+rrHr"r)rZa1r%rrrr�test_extend�s

+
zCommonTest.test_extendcCs�|jdddg�}|jdd�|jdd	�|jdd�|j|d
dddddg�|dd�}|jdd�|jd
d�|jdd�|j||jdddddddddg	��|jt|j�dS)NrrrZfoor(�left�rightrPrFrPrFrPi8���rPrF)r
�insertrr"r)rrrrrr�test_inserts"4zCommonTest.test_insertcCs�|jd	ddg�}|j�|j|d
dg�|jd�|j|dg�|jt|jd�|jd�|j|g�|jt|j�|jt|jdd�|jdddddg�}dS)Nrrr
�*r4r3��(rFrF)r
�poprr"rRr)rrrrr�test_pops


zCommonTest.test_popcs|jdddg�}|jd�|j|ddg�|jd�|j|dg�|jd�|j|g�|jt|jd�|jt|j�Gdd�dt��G�fdd�d�}|jddddg�}|j�|j|��G�fd	d
�d
�}|jd�}|jd�|j||jd
��|jd�|j||jd��|jt|jd�|j||jd��|jdd|�dg�}|j|�}|j�|jd�x-t||�D]\}}|j||�q�WdS)Nrrc@seZdZdS)z&CommonTest.test_remove.<locals>.BadExcN)�__name__�
__module__�__qualname__rrrr�BadExc9srlcs"eZdZ�fdd�ZdS)z&CommonTest.test_remove.<locals>.BadCmpcs|dkr���dS)NrFr)r�other)rlrr�__eq__=s	z-CommonTest.test_remove.<locals>.BadCmp.__eq__N)rirjrkrnr)rlrr�BadCmp<srorrcs"eZdZ�fdd�ZdS)z'CommonTest.test_remove.<locals>.BadCmp2cs
���dS)Nr)rrm)rlrrrnFsz.CommonTest.test_remove.<locals>.BadCmp2.__eq__N)rirjrkrnr)rlrr�BadCmp2EsrpZabcdefghcij�cZ
abdefghcijZ	abdefghijrr)	r
r0rr"rAr�	Exception�zip�assertIs)rrrorpr1�er5�yr)rlr�test_remove,s4




zCommonTest.test_removecs�|jdddg�d}|j|jd�d�|j|jd�d�|j|jd�d�|jt|j�Gdd�dt��G�fdd�d�}|j�|j|��dS)	Nrrrrc@seZdZdS)z%CommonTest.test_count.<locals>.BadExcN)rirjrkrrrrrlasrlcs"eZdZ�fdd�ZdS)z%CommonTest.test_count.<locals>.BadCmpcs|dkr���dS)NrFr)rrm)rlrrrnes	z,CommonTest.test_count.<locals>.BadCmp.__eq__N)rirjrkrnr)rlrrrodsro)r
r�countr"rrr)rrror)rlr�
test_countYszCommonTest.test_countcs�|jddg�}|j|jd�d�|j|jd�d�|jt|jd�|jddddddg�}|j|jd�d�|j|jd�d�|j|jdd�d�|j|jdd�d�|j|jdd�d�|j|jddd�d�|jt|jddd�|jt|j�Gdd�dt��G�fd	d
�d
�}|jddddg��|j��j|��|jddddddg��|j�jd�d�|j�jdd�d�|j�jdd�d�|j�jdd�d�|j�jdd�d�|j�jdd�d�|j�jddd�d�|j�jddd�d�|j�jddtj	dtj	�d�|jt�jddtj	dtj	�|jt�jddd��j
d�|jt�jddd�|j�|jd d!dddg��Gdd�d��|j����fd
d�td�D��dd�<|jt�jd�dS)"Nrrrr4rr	c@seZdZdS)z%CommonTest.test_index.<locals>.BadExcN)rirjrkrrrrrl}srlcs"eZdZ�fdd�ZdS)z%CommonTest.test_index.<locals>.BadCmpcs|dkr���dS)NrFr)rrm)rlrrrn�s	z,CommonTest.test_index.<locals>.BadCmp.__eq__N)rirjrkrnr)rlrrro�sroc@s(eZdZdd�Zdd�ZdS)z&CommonTest.test_index.<locals>.EvilCmpcSs
||_dS)N)�victim)rrzrrrr�sz/CommonTest.test_index.<locals>.EvilCmp.__init__cSs|jdd�=dS)NF)rz)rrmrrrrn�sz-CommonTest.test_index.<locals>.EvilCmp.__eq__N)rirjrkrrnrrrr�EvilCmp�sr{csg|]}����qSrr)�.0�_)r{rrr�
<listcomp>�s	z)CommonTest.test_index.<locals>.<listcomp>rrPrFrPi����i����rPrF���rPi����rQrQrPrri����rPrF)r
r�indexr"rArxrrrr �maxsizer0r)r�uror)rlr{rr�
test_indexlsH!!-*
(,zCommonTest.test_indexcCs�|jdddddg�}|dd�}|j�|j|dddddg�|j�|j||�|jt|jd�dS)	NrrrrdrPrFrFrP)r
�reverserr"r)rr��u2rrr�test_reverse�s

zCommonTest.test_reversecCs�|jdddg�}|j�|j|g�|jg�}|j�|j|g�|jg�}|jd�|j�|jd�|j|dg�|jt|jd�dS)Nrrr	r)r
�clearrrr"r)rr�rrr�
test_clear�s




zCommonTest.test_clearcCs2|jdddg�}|j�}|j|dddg�|jg�}|j�}|j|g�|jddg�}|j�}|jd�|j|ddg�|j||dg�|jddddgdg�}|j�}|j||�|j|d|d�|jt|jd�dS)	Nrrrrrr&r	r
)r
�copyrrrtr"r)rr��vrrr�	test_copy�s 
!zCommonTest.test_copycs�|jddg�}|j�|j|ddg�|jdddd
dg�}|j�|j||jdddddg��|jt|jdd�dd�}|jdt|��|j||jdddddg��dd	�}|jtd
����jdt|��|jt�jd��fdd�}|jt�jdt|��|jt�jdddd�dS)NrrrrdcSs(||krdS||kr dSdSdS)NrrrFr)rrrrr�revcmp�s
z$CommonTest.test_sort.<locals>.revcmp�keycSs=|d|d}}||kr%dS||kr5dSdSdS)Nrr6rrrFr)r5rvZxmodZymodrrr�myComparison�sz*CommonTest.test_sort.<locals>.myComparisonr9cs5�jd�||krdS||kr-dSdSdS)NrrrF)r)r5rv)�zrr�selfmodifyingComparison�s
z5CommonTest.test_sort.<locals>.selfmodifyingComparisonrFrPrPrFrFrP)r
�sortrr"rrrrA)rr�r�r�r�r)r�r�	test_sort�s$

((
zCommonTest.test_sortcCs9|jd�}d|dd�<|j|td��dS)Nr\�hrZham)r
rrH)rr�rrr�
test_sliceszCommonTest.test_slicecs�t�j�|jddg�}|}|ddg7}|j||�|jd�}|d7}|j||jd��|jt|jd�dS)Nrrrrr\r]r^)�super�	test_iaddr
rtrr"r�__iadd__)rr�r�)�	__class__rrr�
s

zCommonTest.test_iaddc	Cs�|jddg�}|d9}|j||jddddddg��|d9}|j||jg��|jg�}t|�}|d9}|jt|�|�dS)Nrrrr4)r
rr)rr��sZoldidrrr�	test_imuls
+

zCommonTest.test_imulc
Cs�|jdddddg�}|ddd�=|j||jddg��|jtd��}|ddd�=|j||jdddg��|jtd��}|ddd�=|j||jddddg��|jtd��}|ddd�=|j||jdddddd	d
ddg	��|jtd��}dgd|ddd�<|j||jdddddddd
ddg
��|jtd��}dgd|ddd�<|j||jddddddd	d
ddg
��|jtd��}||ddd�<|j||jddddg��|jtd��}|dd�}|dd�}|jd
dg�|dd�<|jd
dg�|tdd�<|jd
dg�|dd�<|j||�|j||�|jtd��}ttd��|ddd�<|j||jdddddddd
ddg
��|jtd��}|ddd�=dS)Nrrrrr	r
r4i�rr6rOr7Ztwo�elementsiMrPrFrFrFrFrFrFrrFl)r
rrrCrV)rrrrqrrr�test_extendedslicing%sD"%477%"7zCommonTest.test_extendedslicingcCs0Gdd�dt�}|jtt|��dS)Nc@seZdZdd�ZdS)z9CommonTest.test_constructor_exception_handling.<locals>.FcSs
t�dS)N)�KeyboardInterrupt)rrrr�__iter__QszBCommonTest.test_constructor_exception_handling.<locals>.F.__iter__N)rirjrkr�rrrr�FPsr�)�objectr"r�rH)rr�rrr�#test_constructor_exception_handlingNsz.CommonTest.test_constructor_exception_handlingcCs�|jdddg�}t|�}t|�}x|D]}t|�q7W|jd�|jt|�g�|jt|�dg�|j||jddddg��dS)Nrrrr7)r
�iterrJrrrH)rrZexhitZempitr5rrr�test_exhausted_iteratorUs

z"CommonTest.test_exhausted_iterator)rirjrkrrr'r2rErLrSrUrYrZr[r_rcrhrwryr�r�r�r�r�r�r�r�r�r�r�rr)r�rrs6
%.)	
-9
0
)r)	�__doc__r r/�	functoolsrZtestrrrrrrr�<module>s