Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/list_tests.cpython-34.pyc

�
f fE�@sadZddlZddlZddlmZddlmZmZGdd�dej�ZdS)z,
Tests common to list and UserList.UserList
�N)�
cmp_to_key)�support�	seq_testscsBeZdZdd�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*�Z�fd+d,�Zd-d.�Zd/d0�Zd1d2�Z�S)3�
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/python34/lib64/python3.4/test/list_tests.py�	test_inits
"zCommonTest.test_initcCs@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�RuntimeError)rZl0�l2Za0�a2�irrr�	test_repr!s"


zCommonTest.test_reprcCs�|jtd��}|j|�|jtdd��|j|�|jd�zittjd��}|jt|��WdQXttjd��#}|j	|j
�t|��WdQXWdtj
tj�XdS)N��i��w�r)r
rr�extend�openrZTESTFN�writerr�readr�os�remove)r�dZforrr�
test_print7s


&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__�slice�	TypeError�__getitem__r)rrrrr�test_set_subscriptEs."+*zCommonTest.test_set_subscriptcCs�|jtd��}t|�}|jt|�|jtddd���|jtt|�|jtt|j���|j��|jtt	tdddg��dS)Nr.r;rrr���rB)
r
r�reversedr�listr�
StopIteration�nextr?�len)rrr%rrr�
test_reversedPs+
zCommonTest.test_reversedcCsF|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��dS)Nrrrr#rrr	r
rr1�X�c�r2rB������rBrLrBrLrB)r
rr�
IndexErrorr=r?)rrrrr�test_setitemZs:






(


(

(

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)NrrrrrLrBrM)r
rrrN�__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
r/rMrMrLrBrLrBrBrB)r
rr�tuplerr?r=r>)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)
NrrrrLrBrLrBrBrB)r
r)rrrrr�
test_delslice�s>












zCommonTest.test_delslicecCso|jg�}|jd�|jd�|jd�|j||jdddg��|jt|j�dS)Nrrr)r
rrrr?)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rDrr?)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�rightrLrBrLrBrLi8���rLrB)r
�insertrrr?)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
�*r/r.��(rBrB)r
�poprrrNr?)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�BadExc/srhcs"eZdZ�fdd�ZdS)z&CommonTest.test_remove.<locals>.BadCmpcs|dkr���ndS)NrFr)r�other)rhrr�__eq__3sz-CommonTest.test_remove.<locals>.BadCmp.__eq__N)rerfrgrjr)rhrr�BadCmp2srkrrcs"eZdZ�fdd�ZdS)z'CommonTest.test_remove.<locals>.BadCmp2cs
���dS)Nr)rri)rhrrrj<sz.CommonTest.test_remove.<locals>.BadCmp2.__eq__N)rerfrgrjr)rhrr�BadCmp2;srlZabcdefghcij�cZ
abdefghcijZ	abdefghijrr)	r
r+rrr<r?�	Exception�zip�assertIs)rrrkrlr,�er0�yr)rhr�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)rerfrgrrrrrhWsrhcs"eZdZ�fdd�ZdS)z%CommonTest.test_count.<locals>.BadCmpcs|dkr���ndS)NrFr)rri)rhrrrj[sz,CommonTest.test_count.<locals>.BadCmp.__eq__N)rerfrgrjr)rhrrrkZsrk)r
r�countrr?rn)rrrkr)rhr�
test_countOszCommonTest.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)"Nrrrr/rr	c@seZdZdS)z%CommonTest.test_index.<locals>.BadExcN)rerfrgrrrrrhssrhcs"eZdZ�fdd�ZdS)z%CommonTest.test_index.<locals>.BadCmpcs|dkr���ndS)NrFr)rri)rhrrrjwsz,CommonTest.test_index.<locals>.BadCmp.__eq__N)rerfrgrjr)rhrrrkvsrkc@s(eZdZdd�Zdd�ZdS)z&CommonTest.test_index.<locals>.EvilCmpcSs
||_dS)N)�victim)rrvrrrr�sz/CommonTest.test_index.<locals>.EvilCmp.__init__cSs|jdd�=dS)NF)rv)rrirrrrj�sz-CommonTest.test_index.<locals>.EvilCmp.__eq__N)rerfrgrrjrrrr�EvilCmp�srwcsg|]}����qSrr)�.0�_)rwrrr�
<listcomp>�s	z)CommonTest.test_index.<locals>.<listcomp>rrLrBrLi����i����rLrB���rLi����rMrMrLr{r{i����rLrB)r
r�indexrr<rtr?rnr�maxsizer+r)r�urkr)rhrwrr�
test_indexbsH!!-*
(,zCommonTest.test_indexcCs�|jdddddg�}|dd�}|j�|j|dddddg�|j�|j||�|jt|jd�dS)	Nrrrr`rLrBrBrL)r
�reverserrr?)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rrr?)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rrprr?)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)Nrrrr`cSs(||krdS||kr dSdSdS)NrrrBr)rrrrr�revcmp�s
z$CommonTest.test_sort.<locals>.revcmp�keycSs=|d|d}}||kr%dS||kr5dSdSdS)Nrr1rrrBr)r0rrZxmodZymodrrr�myComparison�sz*CommonTest.test_sort.<locals>.myComparisonr4cs5�jd�||krdS||kr-dSdSdS)NrrrB)r)r0rr)�zrr�selfmodifyingComparison�s
z5CommonTest.test_sort.<locals>.selfmodifyingComparisonrBrLrLrBrBrL)r
�sortrrr?rrr<)rr~r�r�r�r)r�r�	test_sort�s$

((
zCommonTest.test_sortcCs9|jd�}d|dd�<|j|td��dS)NrX�hrZham)r
rrD)rr~rrr�
test_slice�szCommonTest.test_slicecs�t�j�|jddg�}|}|ddg7}|j||�|jd�}|d7}|j||jd��|jt|jd�dS)NrrrrrXrYrZ)�super�	test_iaddr
rprrr?�__iadd__)rr~r�)�	__class__rrr�s

zCommonTest.test_iaddc	Cs�|jddg�}|d9}|j||jddddddg��|d9}|j||jg��|jg�}t|�}|d9}|jt|�|�dS)Nrrrr/)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
r/i�rr1rKr2Ztwo�elementsiMrLrBrBrBrBrBrBr{rBl)r
rrr>rR)rrrrmrrr�test_extendedslicingsD"%477%"7zCommonTest.test_extendedslicingcCs0Gdd�dt�}|jtt|��dS)Nc@seZdZdd�ZdS)z9CommonTest.test_constructor_exception_handling.<locals>.FcSs
t�dS)N)�KeyboardInterrupt)rrrr�__iter__GszBCommonTest.test_constructor_exception_handling.<locals>.F.__iter__N)rerfrgr�rrrr�FFsr�)�objectrr�rD)rr�rrr�#test_constructor_exception_handlingDsz.CommonTest.test_constructor_exception_handling)rerfrgrr"r-rArHrOrQrUrVrWr[r_rdrsrurr�r�r�r�r�r�r�r�r�rr)r�rrs2
!.)	
-9
0
)r)	�__doc__rr*�	functoolsrZtestrrrrrrr�<module>s