403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_itertools.cpython-36.opt-1.pyc
3

�w2_��@sfddlZddlmZddlTddlZddlmZddlmZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlZejZedZdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�d�Zdd�Zdd�Zdd�Zd d!�Z d"d#�Z!d$d%�Z"d&d'�e#ej$d�D�Z%Gd(d)�d)ej&�Z'Gd*d+�d+ej&�Z(Gd,d-�d-ej&�Z)Gd.d/�d/ej&�Z*d0d1�Z+Gd2d3�d3�Z,Gd4d5�d5�Z-Gd6d7�d7�Z.Gd8d9�d9�Z/Gd:d;�d;�Z0Gd<d=�d=�Z1Gd>d?�d?�Z2d@dA�Z3GdBdC�dCej&�Z4GdDdE�dEej&�Z5GdFdG�dGej&�Z6GdHdI�dIej&�Z7ej8GdJdK�dKej&��Z9dLZ:dMe:iZ;dSdNdO�Z<e=dPk�rbe<dQdR�dS)T�N)�support)�*)�Decimal)�Fraction)�reduce�cGstt|��S)N)�list�zip)�args�r�8/opt/alt/python36/lib64/python3.6/test/test_itertools.py�lzipsr
cCsd|S)zTest function of one argument�r)�xrrr�oneargsrcGst�dS)z"Test function that raises an errorN)�
ValueError)r
rrr�errfuncsrccsxdD]
}|VqWdS)zNon-restartable source sequencerrrN)rrrr)�irrr�gen3s
rcCs|ddkS)zTest predicaterrr)rrrr�isEven!srcCs|ddkS)zTest predicaterrr)rrrr�isOdd%srcGs|S)Nr)r
rrr�tupleize)srccsxt|�D]
}|Vq
WdS)N)�range)�nrrrr�irange,src@s eZdZdZdd�Zdd�ZdS)�StopNowz"Class emulating an empty iterable.cCs|S)Nr)�selfrrr�__iter__2szStopNow.__iter__cCst�dS)N)�
StopIteration)rrrr�__next__4szStopNow.__next__N)�__name__�
__module__�__qualname__�__doc__rrrrrrr0srcCstt||��S)zHConvenience function for partially consuming a long of infinite iterable)r�islice)r�seqrrr�take7sr&cCsttj|d�S)Nr)r�operator�mul)�iterablerrr�prod;sr*cCsttd|d��S)Z	Factorialr)r*r)rrrr�fact>sr+cCs|dS)Nrr)�rrrr�testRCsr-cCs|dS)Nrr)r,rrr�testR2Fsr.cCs|dkS)N�
r)rrrr�undertenIsr0cCsg|]}|fdd��qS)cSstjtj||��S)N)�pickle�loads�dumps)�s�protorrr�<lambda>Lsz<listcomp>.<lambda>r)�.0r5rrr�
<listcomp>Lsr8c@s�eZdZd_dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	e
jdd��Ze
j
d�dd��Zdd�Ze
jdd��Ze
j
d�dd��Zdd�Ze
jdd ��Ze
j
d�d!d"��Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Ze
j
d�d7d8��Zd9d:�Z e
j
d�d;d<��Z!d=d>�Z"d?d@�Z#dAdB�Z$e
jdCdD��Z%e
j
d�dEdF��Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdN�Z*dOdP�Z+dQdR�Z,dSdT�Z-dUdV�Z.dWdX�Z/dYdZ�Z0d[d\�Z1d]d^�Z2dS)`�TestBasicOps�rNcsd��fdd�	�tj||�}tj|�}|jt|�t|���|��|�}}	|j||	�|rp�|�}
|j||
�tj|�}d}y&x t|�D]}
t|�|d7}q�WWntk
r�YnXtj||�}tj|�}�|��|�}}	|j||	�|�r�||d��}
|j||
�dS)zITest that an iterator is the same after pickling, also when part-consumedrcsZ�dkrtd��t|t�r|Sytt|���}Wntk
rD|SX��fdd�|D�S)Nr/zinfinite recursion encounteredcsg|]}�|�d��qS)rr)r7�e)�expandrrrr8]sz;TestBasicOps.pickletest.<locals>.expand.<locals>.<listcomp>)�RuntimeError�
isinstance�strrr$�	TypeError)�itr�l)r<�stop)rrr<Ss
z'TestBasicOps.pickletest.<locals>.expandrN)r)r1r3r2�assertEqual�typer�nextr)rZprotocolrArCr&�compare�dumpZi2�a�b�cZi3ZtookrZi4r)r<rCr�
pickletestQs0



zTestBasicOps.pickletestcCs,|jtttd���ddddddddd	d
g
�|jtttd�d��ddddddddd	d
g
�xPttttfD]@}|jttt|td����tt|ddddddddd	d
g
���qhW|jttd��d
ddg�|jttg��g�|jttdg��dg�|j	t
ttd�dd�|j	t
t�|j	t
ttd�d�|j	t
ttdgg��ddddddddddg
}|jtt|t��ddddddddddg
�|jtt|t��ddddddddddg
�|jtt|t
j��ddddddddddg
�|j	t
��tt|t��WdQRXx,ttjd�D]}|j|ttd����q
WdS)Nr/rr������$�-)r)�abcrI�ab��)rr��	r:��i�i�)rDr�
accumulater�int�complexrr�map�assertRaisesr@�min�maxr'r(�chrr1�HIGHEST_PROTOCOLrL)r�typr4r5rrr�test_accumulatezs4(zTestBasicOps.test_accumulatecCs�dd�}x�t|fD]z}|jt|dd��td��|jt|d��td��|jt|d��g�|jtd|dd��td��|jtt|d	d
��qWdS)Ncws&x |D]}x|D]
}|VqWqWdS)zPure python version in the docsNr)�	iterablesrA�elementrrr�chain2�s

z'TestBasicOps.test_chain.<locals>.chain2rT�def�abcdef�r:�abcdrrM)�chainrDrr&r`r@)rrirKrrr�
test_chain�szTestBasicOps.test_chaincCs�|jttjddg��td��|jttjdg��td��|jttjdg��g�|jtdtjddg��td��|jtttjddg��dS)	NrTrjrkrlr:rmrrM)rDrrn�
from_iterabler&r`r@)rrrr�test_chain_from_iterable�s
 z%TestBasicOps.test_chain_from_iterablecCs�x�tjgtD]�}tdd�}|jt||��td��|jt|�d�|jt||��td��|jt|td���g�|jtd|tdd���td��|jt	t|td	d
���qWx0t
tjd�D]}|j
|tdd�td�d�q�WdS)
NrTrjrkrIZbcdefrlr:rmrrMr)rG)�copy�deepcopy�
picklecopiersrnrDrrFr&r`r@rr1rdrL)rZoperrAr5rrr�test_chain_reducible�s
 z!TestBasicOps.test_chain_reduciblec	Cs�|jtt�jf�|jtt�jg�|jtt�jd�|jtt�jgf�|jtt�jtg�gf�t�}|jtddg�f�|jt|�dddddd	g�t�}|jtddg�td
g�f�|jt|�d
dddddd	g�dS)NrrTrjrIrJrK�dr;�fZghi)r`r@rn�__setstate__�iterrDr)rrArrr�test_chain_setstate�sz TestBasicOps.test_chain_setstatec

s�|jttd�|jttddd�|jttd�|jttdd��x�dd�gtD�]�}|jt|tdd���g�|jt|tdd���ddddd d!g�tdd�}t|�|jt||��d"d#d$d%d&g�|jt|ttd�d
���d'd(d)d*g�ttd�d
�}t|�|jt||��d+d,d-g�qPWdd�}dd�}dd�}�x�td�D�]�}dd�t|�D���xtt|d�D�]b}tt�|��}|jt	|�||k�r�dnt
|�t
|�t
||��|jt	|�t	t|���|j|t|��x�|D]x�|jt	��|�|jt	t���|�|jt��t���|j
t�fdd��D���|jt���fdd��D���q�W|j|t|�|���|j|t|�|���|j|t|�|���x*ttjd�D]}	|j|	t�|���q�W�qlW�qDWdS).NrTrrcSs|S)Nr)rIrrrr6�sz0TestBasicOps.test_combinations.<locals>.<lambda>� �ABCD�A�B�C�Dr:rMrc3s�t|��t��}||krdStt|��}t�fdd�|D��Vx�x.tt|��D]}|||||krPPqPWdS||d7<x*t|d|�D]}||dd||<q�Wt�fdd�|D��VqBWdS)z%Pure python version shown in the docsNc3s|]}�|VqdS)Nr)r7r)�poolrr�	<genexpr>�szHTestBasicOps.test_combinations.<locals>.combinations1.<locals>.<genexpr>rc3s|]}�|VqdS)Nr)r7r)r�rrr��s)�tuple�lenrr�reversed)r)r,r�indicesr�jr)r�r�
combinations1�sz5TestBasicOps.test_combinations.<locals>.combinations1c3sTt|��t��}x>tt|�|�D],}t|�t|�kr t�fdd�|D��Vq WdS)z%Pure python version shown in the docsc3s|]}�|VqdS)Nr)r7r)r�rrr��szHTestBasicOps.test_combinations.<locals>.combinations2.<locals>.<genexpr>N)r�r��permutationsr�sortedr)r)r,rr�r)r�r�
combinations2�s
z5TestBasicOps.test_combinations.<locals>.combinations2c3sTt|��t��}x>tt|�|�D],}tt|��|kr t�fdd�|D��Vq WdS)zPure python version from cwr()c3s|]}�|VqdS)Nr)r7r)r�rrr�szHTestBasicOps.test_combinations.<locals>.combinations3.<locals>.<genexpr>N)r�r��combinations_with_replacementr�set)r)r,rr�r)r�r�
combinations3�s
z5TestBasicOps.test_combinations.<locals>.combinations3rVcSsg|]}d|d�qS)rW�r)r7rrrrr8sz2TestBasicOps.test_combinations.<locals>.<listcomp>c3s|]}|�kVqdS)Nr)r7r;)�valuesrrr�
sz1TestBasicOps.test_combinations.<locals>.<genexpr>csg|]}|�kr|�qSrr)r7r;)rKrrr8s���)r}r~)r}r)r}r�)r~r)r~r�)rr�)r}r)r}r�)r~r)r~r�)rr�)rrr)rrrM)rrrM)rrrM)rrrM)rrrM)rrrM)r`r@�combinationsrrtrDrrFrr�r+r�r��
assertTrue�allr1rdrL)
r�op�testIntermediater�r�r�rr,�resultr5r)rKr�r�test_combinations�sP
6

zTestBasicOps.test_combinationscCs(|jttf��tdd�WdQRXdS)N�AAr�i )r`�
OverflowError�MemoryErrorr�)rrrr�test_combinations_overflowsz'TestBasicOps.test_combinations_overflowz"tuple reuse is specific to CPythonc	CsH|jtttttdd����d�|jttttttdd�����d�dS)N�abcderMr)rDr�r�r_�idr��assertNotEqualr)rrrr�test_combinations_tuple_reuses z*TestBasicOps.test_combinations_tuple_reusec

s�t}|jt|d�|jt|ddd�|jt|d�|jt|dd�xldd�gtD]Z}|jt||dd���ddddddg�|dd�}t|�|jt||��dd d!d"d#g�qRWd
d�}dd
�}dd�}�x�td�D�]�}dd�t|�D���x�t|d�D�]�}t|�|��}	|jt	|	�|||��|jt	|	�t	t
|	���|j|	t|	��tt�|��}
|dk�sp|dk�r~|j|	|
�n|j
t
|	�t
|
�k�x�|	D]��|jt	��|�dd�t��D�}|jt	|�t	t
|���|jt��t���|j
t�fdd��D���|j|�fdd��D���q�W|j|	t|�|���|j|	t|�|���x*ttjd�D]}|j||�|���qdW�q�W�q�WdS)$NrTrrcSs|S)Nr)rIrrrr6)szATestBasicOps.test_combinations_with_replacement.<locals>.<lambda>�ABCr}r~rc3s�t|��t��}|r|rdSdg|}t�fdd�|D��Vxfx*tt|��D]}|||dkrPPqPWdS||dg||||d�<t�fdd�|D��VqBWdS)z%Pure python version shown in the docsNrc3s|]}�|VqdS)Nr)r7r)r�rrr�:szPTestBasicOps.test_combinations_with_replacement.<locals>.cwr1.<locals>.<genexpr>rc3s|]}�|VqdS)Nr)r7r)r�rrr�Bs)r�r�r�r)r)r,rr�rr)r�r�cwr12s

z=TestBasicOps.test_combinations_with_replacement.<locals>.cwr1c3sVt|��t��}x@tt|�|d�D],}t|�t|�kr"t�fdd�|D��Vq"WdS)z%Pure python version shown in the docs)�repeatc3s|]}�|VqdS)Nr)r7r)r�rrr�JszPTestBasicOps.test_combinations_with_replacement.<locals>.cwr2.<locals>.<genexpr>N)r�r��productrr�r)r)r,rr�r)r�r�cwr2Ds
z=TestBasicOps.test_combinations_with_replacement.<locals>.cwr2cSs4|s|rdSdSt||d�t|�t|d�S)Nrr)r+)rr,rrr�numcombsLszATestBasicOps.test_combinations_with_replacement.<locals>.numcombsrVcSsg|]}d|d�qS)rWr�r)r7rrrrr8RszCTestBasicOps.test_combinations_with_replacement.<locals>.<listcomp>rcSsg|]\}}|�qSrr)r7�k�vrrrr8bsc3s|]}|�kVqdS)Nr)r7r;)r�rrr�eszBTestBasicOps.test_combinations_with_replacement.<locals>.<genexpr>csg|]}|�kr|�qSrr)r7r;)rKrrr8gsr�)r}r})r}r~)r}r)r~r~)r~r)rr)r}r~)r}r)r~r~)r~r)rr)r�r`r@rrtrDrrFrr�r�r�r�r��groupbyr�r1rdrL)
r�cwrr�r�r�r�r�rr,r�Z
regular_combsZnorunsr5r)rKr�r�"test_combinations_with_replacement"sL

z/TestBasicOps.test_combinations_with_replacementcCs(|jttf��tdd�WdQRXdS)Nr�r�i@)r`r�r�r�)rrrr�+test_combinations_with_replacement_overflownsz8TestBasicOps.test_combinations_with_replacement_overflowc	CsLt}|jtttt|dd����d�|jttttt|dd�����d�dS)Nr�rMr)r�rDr�r�r_r�r�r)rr�rrr�.test_combinations_with_replacement_tuple_reusets z;TestBasicOps.test_combinations_with_replacement_tuple_reusec	s"|jtt�|jttddd�|jttd�|jttdd�|jttdd��g�|jttdd�|jtttd�d��ddddddg�ddd	�}dd
d�}�x~td�D�]p}d
d�t|�D���xVt|d�D�]D}tt�|��}|jt|�||k�r�dnt|�t||��|jt|�tt	|���|j|t
|��xN|D]F}|jt|�|�|jtt	|��|�|jt�fdd�|D����q@W|j|t|�|���|j|t|�|���||k�r�|j|tt�d���|j|tt����x*tt
jd�D]}|j|t�|���q�Wq�Wq�WdS)NrTrrr{r4rMrc3s@t|��t��}|dkr|n|}||kr,dStt|��}tt||d|d��ddd�}t�fdd�|d|�D��Vx�|�r:x�tt|��D]�}||d8<||dkr�||dd�|||d�||d�<||||<q�||}||||||<||<t�fdd�|d|�D��VPq�WdSq~WdS)z%Pure python version shown in the docsNrc3s|]}�|VqdS)Nr)r7r)r�rrr��szHTestBasicOps.test_permutations.<locals>.permutations1.<locals>.<genexpr>rc3s|]}�|VqdS)Nr)r7r)r�rrr��s���)r�r�rrr�)r)r,rr�Zcyclesrr�r)r�r�
permutations1�s&$ ( z5TestBasicOps.test_permutations.<locals>.permutations1c3sft|��t��}|dkr|n|}x@tt|�|d�D],}tt|��|kr2t�fdd�|D��Vq2WdS)z%Pure python version shown in the docsN)r�c3s|]}�|VqdS)Nr)r7r)r�rrr��szHTestBasicOps.test_permutations.<locals>.permutations2.<locals>.<genexpr>)r�r�r�rr�)r)r,rr�r)r�r�
permutations2�sz5TestBasicOps.test_permutations.<locals>.permutations2rVcSsg|]}d|d�qS)rWr�r)r7rrrrr8�sz2TestBasicOps.test_permutations.<locals>.<listcomp>c3s|]}|�kVqdS)Nr)r7r;)r�rrr��sz1TestBasicOps.test_permutations.<locals>.<genexpr>r�)rr)rr)rr)rr)rr)rr)N)N)r`r@r�rrDrrr�r+r�r�r�r�r1rdrL)rr�r�rr,r��pr5r)r�r�test_permutationszs8

	.
"
zTestBasicOps.test_permutationscCs(|jttf��tdd�WdQRXdS)Nr}rr�i@)r`r�r�r�)rrrr�test_permutations_overflow�sz'TestBasicOps.test_permutations_overflowc	CsH|jtttttdd����d�|jttttttdd�����d�dS)Nr�rMr)rDr�r�r_r�r�r�r)rrrr�test_permutations_tuple_reuse�s z*TestBasicOps.test_permutations_tuple_reusecs(�x td�D�]}dd|�}�x�td�D�]�tt|�d��}tt|���}tt|���}tt|���}|jt|�|��|jt|�|r�t|�d�t��t|d�n��|jt|��|kr�dnt|�t|���|jt|��|kr�dnt|�t��t|���|j|t	t
|���|j|t	t
|���|j|t	t
|���|j|t	t
|���|j|dd�|D��|j|�fd	d�|D��|j|d
d�|D��|j|�fdd�|D��|j|ttt
|�j|���|j|ttt
|�j|���|j|t	t
|�t
|�@��q*WqWdS)NrN�ABCDEFGrX)r�rrcSs g|]}t|�t|�kr|�qSr)r�r)r7�trrrr8�sz3TestBasicOps.test_combinatorics.<locals>.<listcomp>cs g|]}tt|���kr|�qSr)r�r�)r7r�)r,rrr8�scSs g|]}t|�t|�kr|�qSr)r�r)r7r�rrrr8�scs g|]}tt|���kr|�qSr)r�r�)r7r�)r,rrr8�s)
rrr�r�r�r�rDr�r+r�r��filter�__contains__)rrr4r*r�ZpermZcombr)r,r�test_combinatorics�s,:,4zTestBasicOps.test_combinatoricscCs�|jttdddddddgd��td��|jttdddddddg��td��|jttdddddddg��td��|jttdddddddg��td��|jttddddg��td��|jttdddddddg��td	��d
}tjttd�|��}tjtd��}|jtt||��ddd
g|�|jttdtd��|jtttd�d�|jtttd��|jtttd�d��xdd�dd�gt	D]�}x�dddddddgddfdddddddgddfdddddddgddfddddgddfdddddddgd	dfgD]|\}}}}|jt|t||d���t|��|jt|t||���t|��t||�}|�r�t
|�|jt||��t|���q�W�q�WdS)N�ABCDEFrr)�data�	selectors�ACEFrlZACr�ZBCi'rNrMrWcSs
tj|�S)N)rr)rIrrrr6�sz,TestBasicOps.test_compress.<locals>.<lambda>cSs
tj|�S)N)rrrs)rIrrrr6�sZCEFZBCDEFr)rr)rDr�compressrnrpr�rr`r@rtrF)rrr�r�r�Zresult1Zresult2r�rrr�
test_compress�s6(&&& & & 
zTestBasicOps.test_compressc	Csn|jtdt��ddd g�|jtdtd��d!d"d#g�|jtdtdtd���d$d%g�|jtdtdtd&���d(d)g�|jtdtdtd*���d,d.g�|jttddd	�|jttd�|jtdttd
��tt	td
td
���|jtdttd
��tt	td
td
���|jtdtd��dd
dg�|jtdtd/��d0d1d2g�|jtdtt
d���t
d�t
d�t
d�g�|jtdttdd���tdd�td
d�tdd�g�dd>}|jtdt|��||d|dg�td�}|jt|�d�t
|�|jt|�d�td3�}|jt|�d�t
|�|jt
|�d4�|jttd��d�|jttd��d�|jtt
td���t�x\tjd
tjd
d5d6ddtjd
tjd
fD](}tt|��}dj|�}|j||��q�Wx|d7dtd
td
fD]d}t|�}|jt
tj|��|�|jt
tj|��|�x(t	tjd�D]}|j|t|���q4W�q�Wtdtd
�tj�dS)8NrTrIrrJrrKrrMr:rWr/g
@g@g@y@z1.1z2.1z3.1rXi�zcount(3)zcount(4)rYz	count(-9)g�$@zcount(10.25)g$@zcount(10.0)z	count(%r))rIr)rJr)rKr)rIrM)rJr:)rKrW)rIrM)rJr:r�r�)rIr�)rJr���r�)rIr�r�)rJr�y
@�y
@�y@�y@�i����i����i����r�r�)rDr
�countr&r	r`r@�maxsizerrrr�reprrFrE�float�sys�__mod__rrrsr1rdrL�exc_info)r�BIGINTrKr�r1�r2�valuer5rrr�
test_countsT   $6
zTestBasicOps.test_countcCsv|jtdtdd��d2d3d4g�|jtdtddd	��d5d6d7g�|jtdtd8d��d9d;d=g�|jttdd�|jtdtdd��d>d?d@g�|jtdtdd
��dAdBdCg�|jtdtdd��dDdEdFg�|jtdttdd��tdttdtdd���|jtdttdd��tdttdtdd���|jtdtdtd��ttdddtdtd���|jtdtdd��dddg�|jtdtddG��ddHdIg�|jtdtt	d�t	d���t	d�t	d�t	d�g�|jtdtt
dd�t
d
d���t
dd�t
dd�t
dd�g�d
d >}|jtdt|d��d|d|g�|jttdtdd!���tdd"d#g��tdd�}|jt|�d$�t|�|jt|�d%�tdJd�}|jt|�d'�t|�|jt|�d'�tdKdL�}|jt|�d(�t|�|jt|�d)�|jt|�d)�|jttd*d��d+�|jttd*d
��d,�|jttd*d-��d.�|jttdd-��d/�tdd-�}|jt
t|��t�|jt
t|��t�x�tjdtjddMdNddtjdtjdfD]�}x�tjdtjddOdPdd
dtjdtjdf	D]l}tt||��}|d
k�r"d0|}nd1||f}|j||�x*ttjd
�D]}|j|t||���qJW�q�W�q�WdS)QNrTrrMrIrJrWrKrX)�start�stepr)r�rr:�rO�dr/g�?g
@g@y@g@g!@y @z1.1z.1z1.2z1.3rV�rPi�g@g)@g.@zcount(3, 5)zcount(8, 5)rYzcount(-9, 0)z
count(-9, -3)zcount(-12, -3)g%@zcount(10.5, 1.25)zcount(10.5)g�?zcount(10.5, 1.0)zcount(10, 1.0)z	count(%r)z
count(%r, %r))rIr)rJrW)rKrX)rIr)rJrW)rKrXr�)rIrr�)rJr�r�)rKr�)rIr)rJr)rKr)rIr)rJrM)rKr:)rIr)rJrW)rKrXy
@�y@�y!@ �i����i����r�i����r�i����r�)rDr
r�r`r@r&r�rrrrr�rFrEr]r�r�r1rdrL)rr�rKrr�r�r�r5rrr�test_count_with_stride6sf28""&



68

z#TestBasicOps.test_count_with_stridecs|jtdtd��td��|jttd��g�|jtt�|jttd�|jtttt��d��ddddddddddg
�td��|jt��d	�|jtdt	j
���td
��xvttj
d�D]d}|jtdtjtj�|���td
��t��|jtdtjtj�|���td��t��t��q�Wx(ttj
d�D]}|j|td���q4Wx�ttj
d�D]�}td�}t|���fd
d�td�D�}tj�|�}tj|�}|jtd|�td��td�}t|���fdd�td�D�}tj�|�}tj|�}|jtd|�td���q^WdS)Nr/rTZ
abcabcabcarlrWrrrrIZ
bcabcabcabZ
cabcabcabcr�csg|]}t���qSr)rF)r7r)rKrrr8�sz+TestBasicOps.test_cycle.<locals>.<listcomp>r�Zcdeabcdeabcdeabcdeabcsg|]}t���qSr)rF)r7r)rKrrr8�srV)rDr&�cyclerr`r@r$rrFrrrsrr1rdr2r3rLry)rr5rA�_r�rvr)rKr�
test_cyclems>0



zTestBasicOps.test_cyclecCs td�}|jtd�df�|jtd|�td��td�}|jtd�df�|jtd|�td��|jt��td�jtd�dg�WdQRX|jt�� td�}|jtd�df�WdQRXtd|�|jt��td�jtd�df�WdQRX|jttd	�jf�|jttd	�jgf�dS)
N�defgrTrr�Zdefgabcdefgabcdefgab�abcdefgrrrl)r�rxrrDr&r`r@r�)rrKrrr�test_cycle_setstate�s  
 z TestBasicOps.test_cycle_setstatec
sT|jgttg���|jgttgtd���|jtttdg��|jttd�|jttddd�d�d1d2d3d4d5d6d7d8g}g}xBt|dd��D]0\}}x&|D]}|j||d�|j|�q�Wq�W|j||�xzttj	d�D]h}g}xPtj
tjt|t�|��D]4\}}x(|D] }|j||d�|j|��qW�q�W|j||��q�Wg}xlt|t�D]^\}}xRt|t
�D]D\}}x8|D]0}|j||d�|j||d�|j|��qzW�qlW�qXW|j||�x�ttj	d�D]�}g}x�tj
tjt|t�|��D]l\}}x`tj
tjt|t
�|��D]D\}}x8|D]0}|j||d�|j||d�|j|��q(W�qW�q�W|j||��q�Wdd�t|t�D�}	tdd�|D��}
|jt|	�|
�|jt|	�t|
��d}dd�tt|��D�}|j|dddddg�d d�tt|��D�}|j|dddg�d!d�tt|��D�}|j|d9d:d;d<d=g�td#d�tt|��D�d$d%�dd�}|j|d>d?d@g�Gd&d'�d't��dA�fd(d)�	}dtfd*d+�}
|j�|
|d��|j�|
|d��G�fd,d-�d-�}|�|�dg}|j�|
|td.�|j�|
|���fd/d0��d�_|j�|
dg��d�_|j�|
ddg��dS)BN)�keyrTcSs|S)Nr)rrrrr6�sz+TestBasicOps.test_groupby.<locals>.<lambda>r/rr��rPr�r�
��rrOrMrZ�r�cSs|dS)Nrr)r,rrrr6�scSsg|]\}}|�qSrr)r7r��grrrr8�sz-TestBasicOps.test_groupby.<locals>.<listcomp>cSsg|]}|d�qS)rr)r7r,rrrr8�sZabracadabracSsg|]\}}|�qSrr)r7r�r�rrrr8�srIrJrKrvr,cSs$g|]\}}tt|dd��r|�qS)rr)rr$)r7r�r�rrrr8�scSs g|]\}}tt|��|f�qSr)r�r)r7r�r�rrrr8�srWcSs g|]\}}tt|��|f�qSr)r�r)r7r�r�rrrr8�sT)�reversec@seZdZdS)z0TestBasicOps.test_groupby.<locals>.ExpectedErrorN)r r!r"rrrr�
ExpectedErrorsr�c3s xt|�D]
}dVq
W��dS)NZyo)r)rr)r�rr�
delayed_raises
z0TestBasicOps.test_groupby.<locals>.delayed_raisecs�fdd�t||�D�S)Ncsg|]\}}�|��qSrr)r7r�r�)�funcrrr8	sz;TestBasicOps.test_groupby.<locals>.gulp.<locals>.<listcomp>)r�)r)Zkeypr�r)r�r�gulpsz'TestBasicOps.test_groupby.<locals>.gulpcseZdZ�fdd�ZdS)z+TestBasicOps.test_groupby.<locals>.DummyCmpcs��dS)Nr)r�dst)r�rr�__eq__sz2TestBasicOps.test_groupby.<locals>.DummyCmp.__eq__N)r r!r"r�r)r�rr�DummyCmpsr�)r�cs$�jdkr�jd8_|S��dS)Nrr)�skip)�obj)r��keyfuncrrr�s
z*TestBasicOps.test_groupby.<locals>.keyfunc)rr/r�)rr�rP)rr�rP)rr�rP)rr�r�)rrOr�)rMrZr�)rMr�r�)rWrI)rrJ)rrK)rrv)rr,)rWrI)rr,)rrJ)r)rDrr�r�r`r@�appendrr1rdr2r3r-r.r�r�r��	Exceptionr�)rr4�dupr�r��elemr5ZikZig�keysZexpectedkeysr,r�r�r�r)r�r�r�test_groupby�s�


"

""
&zTestBasicOps.test_groupbyc	Cs�|jttttd���dddg�|jttddddddg��ddg�|jtttdddddg��ddg�|jtdttt���ddddg�|jt	t�|jt	tdd��|jt	tdd�td�d	�|jt	ttd
�|jt	t
ttd�td���dddg}tttd��}|jttj|��|�tttd��}|jttj|��|�xrtt
jd�D]`}tttd��}|jtt
jt
j||���|�t
|�|jtt
jt
j||���|dd���qPWx2tt
jd�D] }tttd��}|j||��q�WdS)NrNrrr:rcSs|S)Nr)rrrrr6/sz*TestBasicOps.test_filter.<locals>.<lambda>cSs|S)Nr)rrrrr60srVrM)rDrr�rr�boolr&r�r`r@rFrrrsr1rdr2r3rL)r�ansrKr5rrr�test_filter)s, $$"
,zTestBasicOps.test_filterc	Cs&|jttttd���dddg�|jttddddddg��dddg�|jtttdddddg��dddg�|jtdttt���ddddg�|jt	t�|jt	td	d
��|jt	tdd
�td�d�|jt	ttd�|jt	t
ttd�td���x.ttjd�D]}|j
|tttd����qWdS)NrNrrMrWrrr:rVcSs|S)Nr)rrrrr6Jsz/TestBasicOps.test_filterfalse.<locals>.<lambda>cSs|S)Nr)rrrrr6Ks)rDr�filterfalserrr�r&r�r`r@rFr1rdrL)rr5rrr�test_filterfalseDs &&"zTestBasicOps.test_filterfalsecCs*dd�tdt��D�}|j|dddg�|jttdtd
���tdtd
���|jttdtd���tdtd���|jtdtdt���tdtd���|jttd��td��|jtt��t��|jttd�|jtttd�d�|jd
d�tdd�D�tdd��|jdd�tdd�D�tdd��dS)NcSsg|]\}}||f�qSrr)r7r�yrrrr8Ssz)TestBasicOps.test_zip.<locals>.<listcomp>rTrIrrJrrKrrNrkrMcSsg|]}tt|���qSr)r�r)r7�pairrrrr8\srjcSsg|]}|�qSrr)r7r�rrrr8^s)rIr)rJr)rKr)	r	r�rDrrr
r&r`r@)rr�rrr�test_zipQs$$$zTestBasicOps.test_zipcCs�ttttdd���}|jt|�t|��tttttdd����}|jttj	|��t|��dd�t
j
tdt���D�}|j|dddg�dd�t
jtdt���D�}|j|dddg�xLt
tjd�D]:}dd�tjtjtdt��|��D�}|j|dddg�q�WxXt
tjd�D]F}tdt��}t|�d
d�tjtj||��D�}|j|ddg��qWx,t
tjd�D]}|j|tdt����qnWdS)NrTrjcSsg|]\}}||f�qSrr)r7rr�rrrr8isz5TestBasicOps.test_zip_tuple_reuse.<locals>.<listcomp>rIrrJrrKrcSsg|]\}}||f�qSrr)r7rr�rrrr8lscSsg|]\}}||f�qSrr)r7rr�rrrr8pscSsg|]\}}||f�qSrr)r7rr�rrrr8vs)rIr)rJr)rKr)rIr)rJr)rKr)rIr)rJr)rKr)rJr)rKr)rr_r�r	rDrarbr��dict�fromkeysrrr�rsrr1rdr2r3rFrL)r�idsr�r5r�rrr�test_zip_tuple_reuseas$$z!TestBasicOps.test_zip_tuple_reusecsVx�dtd�gtd�dgtd�tdd�tdd�gtd�td�tdd�td	�td
�gtd�td�tdd�td	�td
�td�ggD]x��fdd�tttt����D�}|jtt���|�|jtt�i��|�d
d�|D�}|jtt�tdd���|�q|W|jtdtdt	���tt
dtd����|jtt��tt
���|jttg��tt
g���|jttd��tt
d���|jttdi��tt
td�dgd���|jttd�|jtttd�d�xHdD]@}yt
|t�t��Wntk
�r�YnX|jd|��q�W|jdd�tdd�D�tt
dd���|jdd�tdd�D�tt
dd���dS)NrTrNi�i�i4i�i�ri�i�cs"g|]�t�fdd��D���qS)cs$g|]}�t|�kr|�nd�qS)N)r�)r7�arg)rrrr8�sz;TestBasicOps.test_ziplongest.<locals>.<listcomp>.<listcomp>)r�)r7)r
)rrr8�sz0TestBasicOps.test_ziplongest.<locals>.<listcomp>cSsg|]}tdd�|D���qS)css|]}|dkrdp|VqdS)N�Xr)r7r;rrrr��sz:TestBasicOps.test_ziplongest.<locals>.<listcomp>.<genexpr>)r�)r7r�rrrr8�sr)�	fillvaluerMrkr��zip_longest('abc', fv=1)�3zip_longest('abc', fillvalue=1, bogus_keyword=None)zDid not raise Type in:  cSsg|]}tt|���qSr)r�r)r7r�rrrr8�srjcSsg|]}|�qSrr)r7r�rrrr8�s)rTr�)rr)rrbr_r�rDr�zip_longestr�r&r�r	r`r@�eval�globals�localsZfail)r�targetZstmtr)r
r�test_ziplongest|s@

"0
 (zTestBasicOps.test_ziplongestcCs^ttttdd���}|jt|�t|��tttttdd����}|jttj	|��t|��dS)NrTrj)
rr_r�rrDrarbr�r�r�)rr�rrr�test_zip_longest_tuple_reuse�sz)TestBasicOps.test_zip_longest_tuple_reusecCshxbttjd�D]P}|j|tdd��|j|tdd��|j|tdddd��|j|tdd��qWdS)NrrTrjZdefgh)rrl)rr1rdrLr)rr5rrr�test_zip_longest_pickling�s
z&TestBasicOps.test_zip_longest_picklingcCs�Gdd�d�}|ddt�}|ddt�}dd�}|j|||�ddd
dg�|ddt�}|ddt�}t||d	d
�}|jt|�d�|jt|�d�|jt|�d�|jtt|�dS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z,TestBasicOps.test_bug_7244.<locals>.RepeatercSs||_t|�|_||_dS)N)�or]r�r;)rrr�r;rrr�__init__�s
z5TestBasicOps.test_bug_7244.<locals>.Repeater.__init__cSs|S)Nr)rrrrr�sz5TestBasicOps.test_bug_7244.<locals>.Repeater.__iter__cSs(|jdkr|jd8_|jS|j�dS)Nrr)r�rr;)rrrrr�s
z5TestBasicOps.test_bug_7244.<locals>.Repeater.__next__N)r r!r"r
rrrrrr�Repeater�srrrMrr:cSsTg}xJt||dd�D]8\}}tjd��t||f�WdQRX|j||f�qW|S)Nr)r�stdout)rrZcaptured_output�printr�)r�r�r�rr�rrr�run�sz'TestBasicOps.test_bug_7244.<locals>.runr)r)rr)rr)rr)rr)rr)rr)rr)rrDr=rrFr`)rrr�r�rrArrr�
test_bug_7244�szTestBasicOps.test_bug_7244csx�gfgfdgddgftd�td�gddddd d!gftd�td�td�ggftd�td�td�ggftd�td�td�ggfgD]V\}}|jtt|��|�x8td�D],}|jtt||��tt|t|d	����q�Wq�W|jttttd
�gd���d"�|jtttd�d�dd
�}dd�}dddtd�td�tdddd�td�td�t	td��g	�x�td�D]�}�fdd�tt
jd��D�}tt
t|��}|jttt|���|�|jtt|��t||���|jtt|��t||���t
t|�}|jttt|���|��qbWdS)#NrUrIrJrrMrrr:)r�rVrNcs�ttt|��|jdd�}t|�}|dkr4fVdStdd�|D��rJdSdg|}tdd�t||�D��Vx�x~tt|��D]j}||t||�dkr�q~||d7<xt|d|�D]}d||<q�Wtdd�t||�D��VPq~WdSqpWdS)Nr�rrcss|]}t|�dkVqdS)rN)r�)r7r�rrrr��sz>TestBasicOps.test_product.<locals>.product1.<locals>.<genexpr>css|]\}}||VqdS)Nr)r7r�rrrrr��scss|]\}}||VqdS)Nr)r7r�rrrrr��s)	rr_r��getr��anyr	r�r)r
�kwds�poolsrr�rr�rrr�product1�s&
z+TestBasicOps.test_product.<locals>.product1c?s\ttt|��|jdd�}gg}x|D]��fdd�|D�}q&Wx|D]}t|�VqFWdS)z Pure python version used in docsr�rcs g|]}�D]}||g�qqSrr)r7rr�)r�rrr8sz?TestBasicOps.test_product.<locals>.product2.<locals>.<listcomp>N)rr_r�r)r
rrr�r*r)r�r�product2s

z+TestBasicOps.test_product.<locals>.product2rlrT)rIrJrKr�r�r�r�csg|]}tj���qSr)�randomZchoice)r7r�)�argtypesrrr8sz-TestBasicOps.test_product.<locals>.<listcomp>rW)rI)rJ)rr)rr)rr)rr)rr)rri��)rrDrr�r�r�r`r@r�r�rZ	randranger*r_ry)rr
r�r,rrrZexpected_lenr)rr�test_product�s2$"	
zTestBasicOps.test_productcCs2|jttf��tdgdddi�WdQRXdS)NrUrrWr��r{i)r`r�r�r�)rrrr�test_product_overflowsz"TestBasicOps.test_product_overflowc	CsH|jtttttdd����d�|jttttttdd�����d�dS)NrTrjr)rDr�r�r_r�r�r�r)rrrr�test_product_tuple_reuses z%TestBasicOps.test_product_tuple_reusec
Cs��x�gfgfdgdd	gftd�td�gd
ddd
ddgftd�td�td�ggftd�td�td�ggftd�td�td�ggfgD]d\}}|jttjt|���|�|jttjt|���|�x&ttjd�D]}|j|t|��q�Wq�WdS)NrUrIrJrrMrr)rI)rJ)rr)rr)rr)rr)rr)rr)	rrDrrrr�rsr1rdrL)rr
r�r5rrr�test_product_pickling s$z"TestBasicOps.test_product_picklingcCsLtdd�}|jd�|jt|�d	�td
fd�}|jd�|jtt|�dS)
NrrrMr�)rr)rM)rr )rrM)rr)rM)rrr )r�rxrDrFr`r)rr�rrr�test_product_issue_25021/s


z%TestBasicOps.test_product_issue_25021cCs�|jttddd��dddg�|jttd�td��dddg�|jttdd��dddg�|jtdtd��dddg�|jttdd��g�|jttdd��g�|jtt�|jttddd�|jttdd�td�}|jt|�d	�tdd
�}|jt|�d�t|�|jt|�d�tdd
d�}|jt	|�d�|jtdt
j
|��td��|jtdt
j|��td��x,ttj
d�D]}|j|tdd
d���q~WdS)NrIrM)�object�timesrrrr:yzrepeat((1+0j))rWzrepeat((1+0j), 5)zrepeat((1+0j), 0)r/)rrI)rrI)rrIr�y�?y�?�aar$)rDrr�r
rr&r`r@r�rFrrrsr1rdrL)rr,rKr5rrr�test_repeat9s,
zTestBasicOps.test_repeatcCs`|jttdd��d�|jttdd��d�|jttddd��d�|jttdd	d��d�dS)
NrIrzrepeat('a', 0)r)r#r�r�r�r�)rDr�r�)rrrr�test_repeat_with_negative_timesSsz,TestBasicOps.test_repeat_with_negative_timescCs�|jtttjtd�tdd���d
ddg�|jtttdtd���dddg�|jtttdt���dddg�|jtdttdt���ddg�|jtttjg��g�|j	t
t�|j	t
ttdtd�td���|j	t
ttj�|j	t
ttdtd���|j	t
tttdgdg��|j	t
tttdgdg��dddg}ttdt��}|jttj|��|�ttdt��}|jttj|��|�x2ttjd�D] }ttdt��}|j||��q�WdS)NrMrrVrrrTrWrIrJrKr/r:rrrX)rIr)rJr)rKr)rIr)rJr)rKr)rIr)rJr)rIr)rJr)rKr)rDrr_r'�powrrr�r&r`r@�negrFrrrrrrsr1rdrL)rr�rKr5rrr�test_mapYs.

zTestBasicOps.test_mapc	Cs�|jtttjttd�tdd����d
ddg�|jtdttjtt�td����d
ddg�|jtttjg��g�|jtttjt	ddg�g��dg�|j
ttttjdg��|j
tt�|j
tttjdgd�|j
tttd	dg��|j
t
tttdg��|j
ttttdg��dddg}ttjttd�tdd���}|jttj|��|�ttjttd�tdd���}|jttj|��|�x@ttjd�D].}ttjttd�tdd���}|j||��q�WdS)NrMrrVrrr:rW�extrar/rrrXrrrXi)r:rW)r:rW)r:rW)r:rWrrrX)rDr�starmapr'r'r	rr&r�ryr`r@rFrrrrrrsr1rdrL)rr�rKr5rrr�test_starmapws(" $
zTestBasicOps.test_starmapcCs�x2dD]*}|jtttd�f|���tt|���qWx6dD].\}}|jtttd�f|���tt|���q:W|jtttd�d��ttd���|jtttd�dd��ttd���|jtttd�ddd��ttd���|jtttd�dd��ttdd���|jtttd�ddd��ttddd���ttd��}|jtt|d��ttd���|jt|�ttdd���ttd��}|jtt|dd��g�|jt|�ttdd���td�}|jtt|�|jtt|dddd�|jtt|d dd�|jtt|dd!d"�|jtt|ddd#�|jtt|ddd
�|jtt|d�|jtt|dd�|jtt|dd�|jtt|ddd�|jtt|ddd�|jtttt	�ddt
���d�t	�}|jtt|ddd��dg�|jt|�d�x�d)D]�}|jttjttd�f|����tt|���|jttj
ttd�f|����tt|���x2ttjd�D] }|j|ttd�f|����qFW�q�Wd
d�d*D�}tj|�}t|d�}|j|��t|�tj�|j|��dS)+Nr/r�rMr��nrrr:rWrrI�2css|]
}|VqdS)Nr)r7rrrrr��sz+TestBasicOps.test_islice.<locals>.<genexpr>�r/r�rM�r/rMr��r/r��r/r/�r/rM�r�)r/r0r1r2r3r4�r/r-rM�r/r�rM�r5r6�r/r-�r/r��r8r9�r-�r��r;r<)r7r:r=���r>r�r��r/r�rM�r/rMr��r/r��r/rM�r�)r?r@rArBrC)rr)rDrr$rryr`r@rr�r�r�rFrrrsr1rdrL�weakref�refZassertIsNotNonerZ
gc_collectZassertIsNone)rr
ZtgtargsrAZrarKr5�wrrrr�test_islice�sz"$&&* &

zTestBasicOps.test_islicecCsRddddddddg}|jttt|��dddg�|jtttg��g�|jtt�|jtttj�|jtttjdgd	�|jtttd
d
g��|jt	ttt
dg��ttddddddg�}|jt|�dddg�|jtt|�|jtt
j
tt|���dddg�|jtt
jtt|���dddg�x*ttjd�D]}|j|tt|���q2WdS)NrrMrWr�rr:rNrXr*r/r)r:rW)r:rW)r:rW)rDr�	takewhiler0r`r@r'r'rFrrr�rrrrsrr1rdrL)rr�r�r5rrr�test_takewhile�s "zTestBasicOps.test_takewhilecCs$ddddddddg}|jttt|��dddddg�|jtttg��g�|jtt�|jtttj�|jtttjdgd	�|jtttd
dg��|jt	ttt
d
g��|jttjtt|���dddddg�|jttjtt|���dddddg�x*t
tjd�D]}|j|tt|���qWdS)NrrMrWr�rr:rNrXr*r/)r:rW)r:rW)r:rW)rDr�	dropwhiler0r`r@r'r'rFrrrrrsrr1rdrL)rr�r5rrr�test_dropwhile�s &zTestBasicOps.test_dropwhilecCsd}tg�\}}|jt|�g�|jt|�g�tt|��\}}|jt||�tt|�t|���tt|��\}}|jt|�tt|���|jt|�tt|���tt|��\}}x td�D]}|jt|�|�q�W~|jt|�tt|���tt|��\}}x"td�D]}|jt|�|��qW~|jt|�ttd|���x�td�D]�}dg|dg|}tj|�ggf}tt|��}x(|D] }t||�}	||j	|	��q�W|j|dtt|���|j|dtt|����qFW|j
tt�|j
ttd�|j
ttddgd�|j
ttddgdd�td	�\}}t|�d
�}
|jt|
�td
��ttd�d�\}}}
x"td�D]}|jt|�|��qjW|jt|�ttd���|jt|
�t|
�gttd���|jt|�ttdd���|jt|
�ttdd���|j
ttd	d�|j
t
tgd�x\td�D]P}td	|�}|jt|�t�|jt|�|�|jd
d�|D�td	�g|��qWtd	�\}}t|�\}
}|j||
k�td	�\}
}t|
�}|j
t|�|j
t|d�||
�}|jt|
�t|�k�o�t|�k�o�td	�kn�ttd��\}}tj|�}|jt|d�t|��~|j
tt|d�td	�}ttd��}td	�\}}|jttj|��|�|jttj|��|�tttd���\}}|jttj|��|�|jttj|��|�td	�\}}td|�td|�|jttj|��|dd��|jttj|��|dd��|jt|�|dd��|jt|�|dd��ttd��\}}td|�td|�|jttj|��|dd��|jttj|��|dd��|jt|�|dd��|jt|�|dd��td	�\}}|jttj|��|�|jttj|��|�|jt|�|�|jt|�|�ttd��\}}|jttj|��|�|jttj|��|�|jt|�|�|jt|�|�td	�\}}td|�td|�|jttj|��|dd��|jttj|��|dd��|jt|�|dd��|jt|�|dd��ttd��\}}td|�td|�|jttj|��|dd��|jttj|��|dd��|jt|�|dd��|jt|�|dd��xXttjd�D]F}|j|ttd	���td	�\}}|j|||d�|j|||d��q�WdS)N��r�rWrrrMrrrTrji�ZinvalidcSsg|]}t|��qSr)r)r7rrrrr8Hsz)TestBasicOps.test_tee.<locals>.<listcomp>r/�	__class__i'�<)rGr�)�teerDrrr
rrFrZshuffler�r`r@rErr�r�r�rD�proxy�getattr�ReferenceErrorrrr&rsr1rdrLry)rrrIrJrr��orderZlistsZitsr�rKr�rvZt1Zt2ZtnewZt3r�r�Zlong_ansr5rrr�test_tees� 

 
&<








zTestBasicOps.test_teec	Cs8ttdd��\}}yt|�~Wn~~�YnXdS)Ni-1)rOr�r)rZforwardZbackwardrrr�test_tee_del_backward�sz"TestBasicOps.test_tee_del_backwardcCs,|jttt��x:ttttfD]*}|jtt|g��|jtt|t���qW|jtttgd��|jtttt�d��t	g�\}}|jtt|�|jtt|�t	t��\}}|jtt|�|jtt|�|jttt
dd��xJttt
tttfD]6}|jtt|dd�g��|jtt|dd�t���q�WdS)NrcSs|S)Nr)rrrrr6�sz1TestBasicOps.test_StopIteration.<locals>.<lambda>cSs|S)Nr)rrrrr6�s)r`rrFr	rnr�r�rr$rOr�r�r�r_rHrJr+)rrwr��qrrr�test_StopIteration�s zTestBasicOps.test_StopIteration)r:rN)3r r!r"rLrfrorqrurzr�rZbigaddrspacetestr�Zimpl_detailr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r	r
rrrrrrr!r%r&r)r,rGrIrKrTrUrWrrrrr9Os\
)

PL?!"07*$n
*(:
Q	r9c@s�eZdZdd�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,�Zd-d.�Zd/S)0�TestExamplescCs,|jttdddddg��dddddg�dS)	NrrrMr:rWrNr/rO)rDrr\)rrrrrf�szTestExamples.test_accumulatecCs�dddddg}dddddg}xzttjd�D]h}t|�}|jttjtj||���|dd��|jt|�d�|jttjtj||���|dd��q,Wt|�}|jt|�d�|jtt	j
|��|dd��|jtt	j	|��|dd��dS)	NrrrMr:rWrNr/rO)rr1rdr\rDrr2r3rFrrrs)rr�Zaccumulatedr5rArrr�test_accumulate_reducible�s&*z&TestExamples.test_accumulate_reduciblecCs�tdddgtj�}|jt|�d�x<ttjd�D]*}tjtj	||��}|jt
|�ddg�q2W|jt
tj|��ddg�|jt
tj|��ddg�dS)NrTF)
r\r'�is_rDrFrr1rdr2r3rrrrs)rrAr5Zit_copyrrr�test_accumulate_reducible_none�sz+TestExamples.test_accumulate_reducible_nonecCs|jdjtdd��d�dS)Nrlr��DEFr�)rD�joinrn)rrrrro�szTestExamples.test_chaincCs |jdjtjddg��d�dS)Nrlr�r\r�)rDr]rnrp)rrrrrq�sz%TestExamples.test_chain_from_iterablec	CsH|jttdd��ddd
dddg�|jtttd�d��ddddg�dS)Nr|rr}r~rr�r:rMrr)r}r~)r}r)r}r�)r~r)r~r�)rr�)rrr)rrrM)rrrM)rrrM)rDrr�r)rrrrr��szTestExamples.test_combinationsc	Cs&|jttdd��dddd	d
dg�dS)Nr�rr}r~r)r}r})r}r~)r}r)r~r~)r~r)rr)rDrr�)rrrrr��sz/TestExamples.test_combinations_with_replacementc
Cs*|jttdddddddg��td��dS)Nr�rrr�)rDrr�)rrrrr��szTestExamples.test_compresscCs(|jtttd�d��dddddg�dS)Nr/rWr�r�r�r�)rDrr$r�)rrrrr��szTestExamples.test_countcCs"|jtttd�d��td��dS)Nr|r�ZABCDABCDABCD)rDrr$r�)rrrrr��szTestExamples.test_cyclec	Cs.|jttdd�dddddg��dddg�dS)NcSs|dkS)NrWr)rrrrr6�sz-TestExamples.test_dropwhile.<locals>.<lambda>rr:rN)rDrrJ)rrrrrK�szTestExamples.test_dropwhilecCsT|jdd�td�D�td��|jdd�td�D�td�td�td	�td
�g�dS)NcSsg|]\}}|�qSrr)r7r�r�rrrr8�sz-TestExamples.test_groupby.<locals>.<listcomp>ZAAAABBBCCDAABBBZABCDABcSsg|]\}}t|��qSr)r)r7r�r�rrrr8�sZ
AAAABBBCCDZAAAAZBBB�CCr�)rDr�r)rrrrr��s
zTestExamples.test_groupbycCs,|jttdd�td���dddddg�dS)	NcSs|dS)Nrr)rrrrr6�sz*TestExamples.test_filter.<locals>.<lambda>r/rrMrWrVrY)rDrr�r)rrrrr��szTestExamples.test_filtercCs,|jttdd�td���dddddg�dS)	NcSs|dS)Nrr)rrrrr6sz/TestExamples.test_filterfalse.<locals>.<lambda>r/rrr:rNrX)rDrr�r)rrrrr�szTestExamples.test_filterfalsecCs"|jtttdd	��dddg�dS)
NrrMr/rWr{rYi�)rrMr/)rWrrM)rDrr_r')rrrrr)szTestExamples.test_mapcCst|jttdd��td��|jttddd��td��|jttddd��td��|jttdddd��td��dS)	Nr�r�ABr:�CD�CDEFGr�ACEG)rDrr$)rrrrrGszTestExamples.test_islicecCs|jttdd��ddg�dS)	Nr|�xyr}rr~r�)r}r)r~r�)rDrr	)rrrrr�szTestExamples.test_zipcCs&|jttdddd��ddd
dg�dS)Nr|rc�-)rr}rr~r�rr�)r}r)r~r�)rrd)r�rd)rDrr)rrrr�test_zip_longestszTestExamples.test_zip_longestc
CsL|jttdd��tttdj����|jtttd���ddd	d
ddg�dS)
Nr|rz#AB AC AD BA BC BD CA CB CD DA DB DCrMrr)rrr)rrr)rrr)rrr)rrr)rrr)rDrr�r_r��splitr)rrrrr�szTestExamples.test_permutationscCsT|jttdd��tttdj����|jtttd�dd��d	d
ddd
dddg�dS)Nr|rczAx Ay Bx By Cx Cy Dx DyrrM)r�rr)rrr)rrr)rrr)rrr)rrr)rrr)rrr)rrr)rDrr�r_r�rfr)rrrrrs
zTestExamples.test_productcCs |jttdd��dddg�dS)Nr/rM)rDrr�)rrrrr% szTestExamples.test_repeatcCs&|jtttdd	d
g��dddg�dS)NrrWrMr/r{rYi�)rrW)rMr)r/rM)rDrr+r')rrrr�test_stapmap#szTestExamples.test_stapmapc	Cs,|jttdd�dddddg��ddg�dS)NcSs|dkS)NrWr)rrrrr6(sz-TestExamples.test_takewhile.<locals>.<lambda>rr:rN)rDrrH)rrrrrI'szTestExamples.test_takewhileN)r r!r"rfrYr[rorqr�r�r�r�r�rKr�r�r�r)rGr�rer�rr%rgrIrrrrrX�s.
rXc@s eZdZedd��Zdd�ZdS)�TestPurePythonRoughEquivalentsc
gs�t|�}|jpd|jptj|jp"d}}}tt|||��}yt|�}Wn0t	k
rxxt
t|�|�D]\}}	qhWdSXy0x*t|�D]\}}	||kr�|	Vt|�}q�WWn6t	k
r�x t
t|d|�|�D]\}}	q�WYnXdS)Nrr)�slicer�rCr�r�r�ryrrFrr	�	enumerate)
r)r
r4r�rCr�rAZnextirrhrrrr$-s"$z%TestPurePythonRoughEquivalents.islicecCs6|jt|jdd��td��|jt|jddd��td��|jt|jddd��td��|jt|jdddd��td��ttd	��}|jt|j|d
��ttd
���|jt|�ttd
d	���ttd	��}|jt|j|d
d
��g�|jt|�ttd
d	���t�}|jt|j|dd
d��dg�|jt|�d
�dS)
Nr�rr_r:r`rarrbr/rMrr.)rDrr$ryrr�rF)rrArKrrr�test_islice_recipeCs  z1TestPurePythonRoughEquivalents.test_islice_recipeN)r r!r"�staticmethodr$rkrrrrrh+srhc@s�eZdZdd�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,�Zd-d.�Zd/S)0�TestGCcCs|j|�t|�~~dS)N)r�rF)r�iteratorZ	containerrrr�	makecycleWs
zTestGC.makecyclecCs g}|jtdd|dg�|�dS)NrrrM)ror\)rrIrrrrf\szTestGC.test_accumulatecCsg}|jt|�|�dS)N)rorn)rrIrrrro`szTestGC.test_chaincCsg}|jtj|g�|�dS)N)rornrp)rrIrrrrqdszTestGC.test_chain_from_iterablecCs"g}|jtdd|dgd�|�dS)NrrrM)ror�)rrIrrrr�hszTestGC.test_combinationscCs"g}|jtdd|dgd�|�dS)NrrrM)ror�)rrIrrrr�lsz)TestGC.test_combinations_with_replacementc	Cs&g}|jtdddddddg�|�dS)Nr�rr)ror�)rrIrrrr�pszTestGC.test_compresscCs6g}tdtft|d��}|jt|d�|d��|�dS)N�Int)rrr)rEr]r�ror�)rrIrprrrr�tszTestGC.test_countcCsg}|jt|gd�|�dS)Nr)ror�)rrIrrrr�yszTestGC.test_cyclecCs g}|jttd||g�|�dS)Nr)rorJr�)rrIrrrrK}szTestGC.test_dropwhilecCs$g}|jt|gddd��|�dS)NrcSs|S)Nr)rrrrr6�sz%TestGC.test_groupby.<locals>.<lambda>)ror�)rrIrrrr��szTestGC.test_groupbycCsBd}dd�}x0tt|�|d�D]\}}|jjdg�j|�qWdS)Nr/cSs|S)Nr)rrrrr6�sz'TestGC.test_issue2246.<locals>.<lambda>)r�r)r�r�__dict__�
setdefaultr�)rrr�rr�rrr�test_issue2246�szTestGC.test_issue2246cCs$g}|jtdd�|gd�|�dS)NcSsdS)NTr)rrrrr6�sz$TestGC.test_filter.<locals>.<lambda>r)ror�)rrIrrrr��szTestGC.test_filtercCsg}|jtdd�|�|�dS)NcSsdS)NFr)rrrrr6�sz)TestGC.test_filterfalse.<locals>.<lambda>)ror�)rrIrrrr��szTestGC.test_filterfalsecCs&g}|jt|gd|gd�|�dS)NrrM)ror	)rrIrrrr��szTestGC.test_zipcCsPg}|jt|gd|gd�|�|dg}|jt|gd|gd|d�|�dS)NrrM)r)ror)rrIrJrrrre�szTestGC.test_zip_longestcCs$g}|jtdd�|gd�|�dS)NcSs|S)Nr)rrrrr6�sz!TestGC.test_map.<locals>.<lambda>r)ror_)rrIrrrr)�szTestGC.test_mapcCs g}|jt|gdd�|�dS)Nr)ror$)rrIrrrrG�szTestGC.test_islicecCs"g}|jtdd|dgd�|�dS)NrrrM)ror�)rrIrrrr��szTestGC.test_permutationscCs$g}|jtdd|dgdd�|�dS)NrrrM)r�)ror�)rrIrrrr�szTestGC.test_productcCsg}|jt|�|�dS)N)ror�)rrIrrrr%�szTestGC.test_repeatcCs(g}|jtdd�||fgd�|�dS)NcWs|S)Nr)r�rrrr6�sz%TestGC.test_starmap.<locals>.<lambda>r)ror+)rrIrrrr,�szTestGC.test_starmapcCs"g}|jttdd||g�|�dS)Nrr)rorHr�)rrIrrrrI�szTestGC.test_takewhileN)r r!r"rorfrorqr�r�r�r�r�rKr�rsr�r�r�rer)rGr�rr%r,rIrrrrrmUs.rmccsx|D]
}|VqWdS)zRegular generatorNr)�seqnrrrr�R�s
ruc@s eZdZdZdd�Zdd�ZdS)�GzSequence using __getitem__cCs
||_dS)N)rt)rrtrrrr
�sz
G.__init__cCs
|j|S)N)rt)rrrrr�__getitem__�sz
G.__getitem__N)r r!r"r#r
rwrrrrrv�srvc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Iz Sequence using iterator protocolcCs||_d|_dS)Nr)rtr)rrtrrrr
�sz
I.__init__cCs|S)Nr)rrrrr�sz
I.__iter__cCs2|jt|j�krt�|j|j}|jd7_|S)Nr)rr�rtr)rr�rrrr�s
z
I.__next__N)r r!r"r#r
rrrrrrrx�srxc@s eZdZdZdd�Zdd�ZdS)�Igz9Sequence using iterator protocol defined with a generatorcCs||_d|_dS)Nr)rtr)rrtrrrr
�szIg.__init__ccsx|jD]
}|VqWdS)N)rt)r�valrrrr�szIg.__iter__N)r r!r"r#r
rrrrrry�sryc@s eZdZdZdd�Zdd�ZdS)rz Missing __getitem__ and __iter__cCs||_d|_dS)Nr)rtr)rrtrrrr
�sz
X.__init__cCs2|jt|j�krt�|j|j}|jd7_|S)Nr)rr�rtr)rr�rrrr�s
z
X.__next__N)r r!r"r#r
rrrrrr�src@s eZdZdZdd�Zdd�ZdS)�NzIterator missing __next__()cCs||_d|_dS)Nr)rtr)rrtrrrr
�sz
N.__init__cCs|S)Nr)rrrrr�sz
N.__iter__N)r r!r"r#r
rrrrrr{�sr{c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�EzTest propagation of exceptionscCs||_d|_dS)Nr)rtr)rrtrrrr
�sz
E.__init__cCs|S)Nr)rrrrr�sz
E.__iter__cCsdddS)NrMrr)rrrrr�sz
E.__next__N)r r!r"r#r
rrrrrrr|�sr|c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SzTest immediate stopcCsdS)Nr)rrtrrrr
�sz
S.__init__cCs|S)Nr)rrrrr�sz
S.__iter__cCst�dS)N)r)rrrrr�sz
S.__next__N)r r!r"r#r
rrrrrrr}�sr}cCsttdd�ttt|�����S)z Test multiple tiers of iteratorscSs|S)Nr)rrrrr6szL.<locals>.<lambda>)rnr_ruryrv)rtrrr�Lsr~c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�TestVariousIteratorArgscCs�dddddg}dddddg}t|�}x.tttttfD]}|jtt||���|�q4W|jttt	|���g�|j
ttt|��|j
ttt
|��|j
tttt|���dS)	NrrrMr:rWrNr/rO)r�rvrxryr~rurDrr\r}r`r@rr{�ZeroDivisionErrorr|)rr4r,rr�rrrrf	sz'TestVariousIteratorArgs.test_accumulatecCs�x�ddtd�d	tddd�fD]�}xjttttttfD]V}|jtt	||���t||���|jtt	||�||���t||��t||���q2W|j
ttt	t|���|j
ttt	t
|���|j
ttt	t|���qWdS)
N�123rli��do�333333�?i�i�rW)r�r�)rrvrxryr}r~rurDrrnr`r@rr{r�r|)rr4r�rrrros  6z"TestVariousIteratorArgs.test_chaincCs�x�ddtd�d
tddd�fD]�}t|�}x>ttttttfD]*}|jt	t
||�td	���t	||���q:W|jt
t
t|�td	��|jt
t
t|�td	��|jtt	t
t|�td	���qWdS)Nr�rli�r��333333�?i�i�rWr)r�r�)rr�rvrxryr}r~rurDrr�r�r`r@rr{r�r|)rr4rr�rrrr�s *z%TestVariousIteratorArgs.test_compresscCs^xXddtd�d	tddd�fD]:}|jttt|��|jttt|��|jttt|��qWdS)
Nr�rli�r��333333�?i�i�rW)r�r�)rr`r@r�rr{r�r|)rr4rrrr&s z$TestVariousIteratorArgs.test_productcCs�x�ddtd�d
tddd�fD]�}xVttttttfD]B}t|�d	}t||��d	}tt	t
||��|��}|j||�q2W|jt
t
t|��|jt
t
t|��|jttt
t|���qWdS)Nr�rli�r��333333�?i�i�rWrM)r�r�)rrvrxryr}r~rur�rr$r�rDr`r@rr{r�r|)rr4r�ZtgtlenZexpectedZactualrrrr�,s z"TestVariousIteratorArgs.test_cyclecCs�x�td�td�td�dtddd�fD]~}x>ttttttfD]*}|jd	d
�t||��D�t	||���q:W|j
ttt|��|j
ttt
|��|j
tt	tt|���q$WdS)Nr/ri�rVr�i�i�rWcSsg|]\}}|�qSrr)r7r�Zsbrrrr8:sz8TestVariousIteratorArgs.test_groupby.<locals>.<listcomp>)rVr�)rrvrxryr}r~rurDr�rr`r@rr{r�r|)rr4r�rrrr�7s(*z$TestVariousIteratorArgs.test_groupbycCs�x�td�td�td�dtddd�fD]�}x@ttttttfD],}|jtt	t
||���d	d
�||�D��q:W|jtt	t
t
|��|jtt	t
t|��|jttt	t
t|���q$WdS)Nr/ri�rVr�i�i�rWcSsg|]}t|�r|�qSr)r)r7rrrrr8Csz7TestVariousIteratorArgs.test_filter.<locals>.<listcomp>)rVr�)rrvrxryr}r~rurDrr�rr`r@rr{r�r|)rr4r�rrrr�?s(z#TestVariousIteratorArgs.test_filtercCs�x�td�td�td�dtddd�fD]�}x@ttttttfD],}|jtt	t
||���d	d
�||�D��q:W|jtt	t
t
|��|jtt	t
t|��|jttt	t
t|���q$WdS)Nr/ri�rVr�i�i�rWcSsg|]}t|�r|�qSr)r)r7rrrrr8Lsz<TestVariousIteratorArgs.test_filterfalse.<locals>.<listcomp>)rVr�)rrvrxryr}r~rurDrr�rr`r@rr{r�r|)rr4r�rrrr�Hs(z(TestVariousIteratorArgs.test_filterfalsecCs�x�ddtd�d	tddd�fD]�}xdttttttfD]P}|jtt	||���t
||���|jtt	||�||���t
||�||���q2W|jtt	t
|��|jtt	t|��|jttt	t|���qWdS)
Nr�rli�r��333333�?i�i�rW)r�r�)rrvrxryr}r~rurDrr	r
r`r@rr{r�r|)rr4r�rrrr�Qs  0z TestVariousIteratorArgs.test_zipc	Cs�x�ddtd�d	tddd�fD]�}xlttttttfD]X}|jtt	||���tt
||����|jtt	||�||���tt
||�||����q2W|jtt	t
|��|jtt	t|��|jttt	t|���qWdS)
Nr�rli�r��333333�?i�i�rW)r�r�)rrvrxryr}r~rurDrrr	r`r@rr{r�r|)rr4r�rrrr	Zs $4z'TestVariousIteratorArgs.test_ziplongestc	Cs�x�td�td�td�dtddd�fD]�}xpttttttfD]\}|jtt	t
||���d	d
�||�D��|jtt	tj||�||���dd
�||�D��q:W|j
tt	t
t|��|j
tt	t
t|��|j
ttt	t
t|���q$WdS)
Nr/rr�rVr�r�r.rWcSsg|]}t|��qSr)r)r7rrrrr8gsz4TestVariousIteratorArgs.test_map.<locals>.<listcomp>cSsg|]}||�qSrr)r7rrrrr8is)rVr�)rrvrxryr}r~rurDrr_rr'r'r`r@rr{r�r|)rr4r�rrrr)cs(z TestVariousIteratorArgs.test_mapc	Cs�x�ddtd�dtddd�fD]�}xHttttttfD]4}|jtt	||�d	dd
��t||��d	dd
��q2W|j
tt	t|�d�|j
tt	t
|�d�|j
ttt	t|�d��qWdS)
NZ12345rli�r��333333�?i�i�rWrrr/)r�r�)rrvrxryr}r~rurDrr$r`r@rr{r�r|)rr4r�rrrrGns 4z#TestVariousIteratorArgs.test_islicecCs�x�td�td�td�dtddd�fD]�}xLttttttfD]8}t||�}|jt	t
tj||���d	d
�||�D��q:W|j
tt
tjt|��|j
tt
tjt|��|j
tt	t
tjt|���q$WdS)Nr/rr�rVr�r�r.rWcSsg|]}||�qSrr)r7rrrrr8{sz8TestVariousIteratorArgs.test_starmap.<locals>.<listcomp>)rVr�)rrvrxryr}r~rur
rDrr+r'r'r`r@rr{r�r|)rr4r�Zssrrrr,vs(
z$TestVariousIteratorArgs.test_starmapcCs�x�td�td�td�d	tddd�fD]�}x\ttttttfD]H}g}x$||�D]}t|�sZP|j|�qLW|j	t
tt||���|�q:W|jt
ttt|��|jt
ttt|��|jtt
ttt|���q$WdS)
Nr/ri�rVr�i�i�rW)rVr�)rrvrxryr}r~rurr�rDrrHr`r@rr{r�r|)rr4r��tgtr�rrrrI�s(z&TestVariousIteratorArgs.test_takewhilecCs�x�td�td�td�d	tddd�fD]�}xbttttttfD]N}g}x*||�D]}|r`t|�r`qL|j|�qLW|j	t
tt||���|�q:W|jt
ttt|��|jt
ttt|��|jtt
ttt|���q$WdS)
Nr/ri�rVr�i�i�rW)rVr�)rrvrxryr}r~rurr�rDrrJr`r@rr{r�r|)rr4r�r�r�rrrrK�s(z&TestVariousIteratorArgs.test_dropwhilecCs�x�ddtd�d
tddd�fD]�}xXttttttfD]D}t||��\}}|jt	|�t	||���|jt	|�t	||���q2W|j
ttt|��|j
ttt
|��|j
tt	tt|��d	�qWdS)Nr�rli�r��333333�?i�i�rWr)r�r�)rrvrxryr}r~rurOrDrr`r@rr{r�r|)rr4r�Zit1Zit2rrrrT�s z TestVariousIteratorArgs.test_teeN)r r!r"rfror�rr�r�r�r�r�r	r)rGr,rIrKrTrrrrrs 						
rc@seZdZdd�Zdd�ZdS)�LengthTransparencycCsL|jtjtdd��d�|jtjtdd��d�|jtjtd�d�d�dS)Nr.rr�)rDr'�length_hintr�)rrrrr%�szLengthTransparency.test_repeatcCsh|jtjtdd��d�|jtjtdd��d�|jtjtddd��d�|jtjtddd��d�dS)	Nrrr)r#r�r�r�r�)rDr'r�r�)rrrrr&�sz2LengthTransparency.test_repeat_with_negative_timesN)r r!r"r%r&rrrrr��sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�RegressionTestscs<dd�}�fdd�}g�|d|d�tt�}|j�|�dS)
NcsTdgf��fdd�	}t|�}t|�|dd�<t||�}t|gt|���t��dS)Nrcs|r|dd�=�t���|S)N)rF)r��first)rw�zrrr��s
z@RegressionTests.test_sf_793826.<locals>.mutatingtuple.<locals>.g)rr_r	r�rF)Ztuple1rwZtuple2r��items�genr)rwr�r�
mutatingtuple�s
z5RegressionTests.test_sf_793826.<locals>.mutatingtuplecs|att��dd�<dS)N)�Tr)r�)r�rrrw�sz)RegressionTests.test_sf_793826.<locals>.frrrMr:rWrN)rrrM)r:rWrN)rr�rD)rr�rw�secondr)r�r�test_sf_793826�szRegressionTests.test_sf_793826cs��fdd�}�fdd�}g�|jttt|�|d���|j�ddg�g�|jttt|�|d���|j�ddg�g�|jttt|���|j�ddg�dS)	Nc3s,�jd�dV�jd�t��jd�dS)Nrrr)r��AssertionErrorr)�histrr�gen1�s


z,RegressionTests.test_sf_950057.<locals>.gen1c3s�jd�dV�jd�dS)NrMrr:)r�)r)r�rr�gen2�s
z,RegressionTests.test_sf_950057.<locals>.gen2FrrT)r`r�rrnrDr�)rr�r�r)r�r�test_sf_950057�szRegressionTests.test_sf_950057c	Cs:tjdd�td�D��}|jt��t|�WdQRXdS)Ncss|]
}fVqdS)Nr)r7Zunusedrrrr��szERegressionTests.test_long_chain_of_empty_iterables.<locals>.<genexpr>i���)rnrprr`rrF)rrArrr�"test_long_chain_of_empty_iterables�sz2RegressionTests.test_long_chain_of_empty_iterablescs4�fdd�}x"ttd�|�D]\}�t��qWdS)Ncs|dkrt��|dkS)NrWrN)r)r)rJrrrw�sz,RegressionTests.test_issue30347_1.<locals>.fr/)r�rr)rrwr�r)rJr�test_issue30347_1�sz!RegressionTests.test_issue30347_1csNG��fdd�d�}d�tttd�|��d�xtd�D]}t�d�q8WdS)Ncs"eZdZdd�Z��fdd�ZdS)z,RegressionTests.test_issue30347_2.<locals>.KcSsdS)Nr)rr�rrrr
�sz5RegressionTests.test_issue30347_2.<locals>.K.__init__cs�d7��dkrt�d�dS)NrT)rF)r�other)r�rrrr��s
z3RegressionTests.test_issue30347_2.<locals>.K.__eq__N)r r!r"r
r�r)r�rrr�K�sr�rr/rr)rFr�r)rr�r�r)r�rr�test_issue30347_2�s
	z!RegressionTests.test_issue30347_2N)r r!r"r�r�r�r�r�rrrrr��s
r�c@seZdZdd�ZdS)�SubclassWithKwargsTestcs�x|tttttttttt	t
tfD]\�G�fdd�d��}y|dd�Wqtk
rx}z|j
d|jd�WYdd}~XqXqWdS)NcseZdZd�fdd�	ZdS)zBSubclassWithKwargsTest.test_keywords_in_subclass.<locals>.SubclassNcs�j|f|��dS)N)r
)r�newargr
)�clsrrr
szKSubclassWithKwargsTest.test_keywords_in_subclass.<locals>.Subclass.__init__)N)r r!r"r
r)r�rr�Subclasssr�r)r�zdoes not take keyword argumentsr)r�r	r�r�rnr_r+r$rHrJr�r�r@ZassertNotInr
)rr��errr)r�r�test_keywords_in_subclasssz0SubclassWithKwargsTest.test_keywords_in_subclassN)r r!r"r�rrrrr�
sr�c@s:eZdZdd�ZejZdd�Zdd�Zdd�Zd	d
�Z	dS)�
SizeofTestcCstjd�|_dS)Nr)�structZcalcsize�ssize_t)rrrr�setUpszSizeofTest.setUpcCsFtjd�}|j}|tdd�|d|j�|td�|d|j�dS)	NZ3PirUZ12rrTr/)rT)
rTrTrTrTrTrTrTrTrTrT)r�calcobjsize�check_sizeofr�r�)r�basesize�checkrrr�test_product_sizeofs
zSizeofTest.test_product_sizeofcCsLtjd�}|j}|tdd�|d|j�|ttd�d�|d|j�dS)N�3PnirmrMr/r:)rr�r�r�r�r)rr�r�rrr�test_combinations_sizeof%s
z#SizeofTest.test_combinations_sizeofcCsPt}tjd�}|j}||dd�|d|j�||td�d�|d|j�dS)Nr�rmrMr/r:)r�rr�r�r�r)rr�r�r�rrr�)test_combinations_with_replacement_sizeof+s

z4SizeofTest.test_combinations_with_replacement_sizeofcCs�tjd�}|j}|td�|d|jd|j�|tdd�|d|jd|j�|tdd�|d|jd|j�|ttd�d�|d|jd|j�dS)NZ4Pnirmr:rMr�rWr/)rr�r�r�r�r)rr�r�rrr�test_permutations_sizeof2s


z#SizeofTest.test_permutations_sizeofN)
r r!r"r�rr�r�r�r�r�rrrrr�sr�a�" Doctest for examples in the library reference: libitertools.tex


>>> amounts = [120.15, 764.05, 823.14]
>>> for checknum, amount in zip(count(1200), amounts):
...     print('Check %d is for $%.2f' % (checknum, amount))
...
Check 1200 is for $120.15
Check 1201 is for $764.05
Check 1202 is for $823.14

>>> import operator
>>> for cube in map(operator.pow, range(1,4), repeat(3)):
...    print(cube)
...
1
8
27

>>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura', '', 'martin', '', 'walter', '', 'samuele']
>>> for name in islice(reportlines, 3, None, 2):
...    print(name.title())
...
Alex
Laura
Martin
Walter
Samuele

>>> from operator import itemgetter
>>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
>>> di = sorted(sorted(d.items()), key=itemgetter(1))
>>> for k, g in groupby(di, itemgetter(1)):
...     print(k, list(map(itemgetter(0), g)))
...
1 ['a', 'c', 'e']
2 ['b', 'd', 'f']
3 ['g']

# Find runs of consecutive numbers using groupby.  The key to the solution
# is differencing with a range so that consecutive numbers all appear in
# same group.
>>> data = [ 1,  4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
>>> for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]):
...     print(list(map(operator.itemgetter(1), g)))
...
[1]
[4, 5, 6]
[10]
[15, 16, 17, 18]
[22]
[25, 26, 27, 28]

>>> def take(n, iterable):
...     "Return first n items of the iterable as a list"
...     return list(islice(iterable, n))

>>> def prepend(value, iterator):
...     "Prepend a single value in front of an iterator"
...     # prepend(1, [2, 3, 4]) -> 1 2 3 4
...     return chain([value], iterator)

>>> def enumerate(iterable, start=0):
...     return zip(count(start), iterable)

>>> def tabulate(function, start=0):
...     "Return function(0), function(1), ..."
...     return map(function, count(start))

>>> import collections
>>> def consume(iterator, n=None):
...     "Advance the iterator n-steps ahead. If n is None, consume entirely."
...     # Use functions that consume iterators at C speed.
...     if n is None:
...         # feed the entire iterator into a zero-length deque
...         collections.deque(iterator, maxlen=0)
...     else:
...         # advance to the empty slice starting at position n
...         next(islice(iterator, n, n), None)

>>> def nth(iterable, n, default=None):
...     "Returns the nth item or a default value"
...     return next(islice(iterable, n, None), default)

>>> def all_equal(iterable):
...     "Returns True if all the elements are equal to each other"
...     g = groupby(iterable)
...     return next(g, True) and not next(g, False)

>>> def quantify(iterable, pred=bool):
...     "Count how many times the predicate is true"
...     return sum(map(pred, iterable))

>>> def padnone(iterable):
...     "Returns the sequence elements and then returns None indefinitely"
...     return chain(iterable, repeat(None))

>>> def ncycles(iterable, n):
...     "Returns the sequence elements n times"
...     return chain(*repeat(iterable, n))

>>> def dotproduct(vec1, vec2):
...     return sum(map(operator.mul, vec1, vec2))

>>> def flatten(listOfLists):
...     return list(chain.from_iterable(listOfLists))

>>> def repeatfunc(func, times=None, *args):
...     "Repeat calls to func with specified arguments."
...     "   Example:  repeatfunc(random.random)"
...     if times is None:
...         return starmap(func, repeat(args))
...     else:
...         return starmap(func, repeat(args, times))

>>> def pairwise(iterable):
...     "s -> (s0,s1), (s1,s2), (s2, s3), ..."
...     a, b = tee(iterable)
...     try:
...         next(b)
...     except StopIteration:
...         pass
...     return zip(a, b)

>>> def grouper(n, iterable, fillvalue=None):
...     "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
...     args = [iter(iterable)] * n
...     return zip_longest(*args, fillvalue=fillvalue)

>>> def roundrobin(*iterables):
...     "roundrobin('ABC', 'D', 'EF') --> A D E B F C"
...     # Recipe credited to George Sakkis
...     pending = len(iterables)
...     nexts = cycle(iter(it).__next__ for it in iterables)
...     while pending:
...         try:
...             for next in nexts:
...                 yield next()
...         except StopIteration:
...             pending -= 1
...             nexts = cycle(islice(nexts, pending))

>>> def powerset(iterable):
...     "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
...     s = list(iterable)
...     return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

>>> def unique_everseen(iterable, key=None):
...     "List unique elements, preserving order. Remember all elements ever seen."
...     # unique_everseen('AAAABBBCCDAABBB') --> A B C D
...     # unique_everseen('ABBCcAD', str.lower) --> A B C D
...     seen = set()
...     seen_add = seen.add
...     if key is None:
...         for element in iterable:
...             if element not in seen:
...                 seen_add(element)
...                 yield element
...     else:
...         for element in iterable:
...             k = key(element)
...             if k not in seen:
...                 seen_add(k)
...                 yield element

>>> def unique_justseen(iterable, key=None):
...     "List unique elements, preserving order. Remember only the element just seen."
...     # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B
...     # unique_justseen('ABBCcAD', str.lower) --> A B C A D
...     return map(next, map(itemgetter(1), groupby(iterable, key)))

>>> def first_true(iterable, default=False, pred=None):
...     '''Returns the first true value in the iterable.
...
...     If no true value is found, returns *default*
...
...     If *pred* is not None, returns the first item
...     for which pred(item) is true.
...
...     '''
...     # first_true([a,b,c], x) --> a or b or c or x
...     # first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
...     return next(filter(pred, iterable), default)

>>> def nth_combination(iterable, r, index):
...     'Equivalent to list(combinations(iterable, r))[index]'
...     pool = tuple(iterable)
...     n = len(pool)
...     if r < 0 or r > n:
...         raise ValueError
...     c = 1
...     k = min(r, n-r)
...     for i in range(1, k+1):
...         c = c * (n - k + i) // i
...     if index < 0:
...         index += c
...     if index < 0 or index >= c:
...         raise IndexError
...     result = []
...     while r:
...         c, n, r = c*r//n, n-1, r-1
...         while index >= c:
...             index -= c
...             c, n = c*(n-r)//n, n-1
...         result.append(pool[-1-n])
...     return tuple(result)


This is not part of the examples but it tests to make sure the definitions
perform as purported.

>>> take(10, count())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

>>> list(prepend(1, [2, 3, 4]))
[1, 2, 3, 4]

>>> list(enumerate('abc'))
[(0, 'a'), (1, 'b'), (2, 'c')]

>>> list(islice(tabulate(lambda x: 2*x), 4))
[0, 2, 4, 6]

>>> it = iter(range(10))
>>> consume(it, 3)
>>> next(it)
3
>>> consume(it)
>>> next(it, 'Done')
'Done'

>>> nth('abcde', 3)
'd'

>>> nth('abcde', 9) is None
True

>>> [all_equal(s) for s in ('', 'A', 'AAAA', 'AAAB', 'AAABA')]
[True, True, True, False, False]

>>> quantify(range(99), lambda x: x%2==0)
50

>>> a = [[1, 2, 3], [4, 5, 6]]
>>> flatten(a)
[1, 2, 3, 4, 5, 6]

>>> list(repeatfunc(pow, 5, 2, 3))
[8, 8, 8, 8, 8]

>>> import random
>>> take(5, map(int, repeatfunc(random.random)))
[0, 0, 0, 0, 0]

>>> list(pairwise('abcd'))
[('a', 'b'), ('b', 'c'), ('c', 'd')]

>>> list(pairwise([]))
[]

>>> list(pairwise('a'))
[]

>>> list(islice(padnone('abc'), 0, 6))
['a', 'b', 'c', None, None, None]

>>> list(ncycles('abc', 3))
['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']

>>> dotproduct([1,2,3], [4,5,6])
32

>>> list(grouper(3, 'abcdefg', 'x'))
[('a', 'b', 'c'), ('d', 'e', 'f'), ('g', 'x', 'x')]

>>> list(roundrobin('abc', 'd', 'ef'))
['a', 'd', 'e', 'b', 'f', 'c']

>>> list(powerset([1,2,3]))
[(), (1,), (2,), (3,), (1, 2), (1, 3), (2, 3), (1, 2, 3)]

>>> all(len(list(powerset(range(n)))) == 2**n for n in range(18))
True

>>> list(powerset('abcde')) == sorted(sorted(set(powerset('abcde'))), key=len)
True

>>> list(unique_everseen('AAAABBBCCDAABBB'))
['A', 'B', 'C', 'D']

>>> list(unique_everseen('ABBCcAD', str.lower))
['A', 'B', 'C', 'D']

>>> list(unique_justseen('AAAABBBCCDAABBB'))
['A', 'B', 'C', 'D', 'A', 'B']

>>> list(unique_justseen('ABBCcAD', str.lower))
['A', 'B', 'C', 'A', 'D']

>>> first_true('ABC0DEF1', '9', str.isdigit)
'0'

>>> population = 'ABCDEFGH'
>>> for r in range(len(population) + 1):
...     seq = list(combinations(population, r))
...     for i in range(len(seq)):
...         assert nth_combination(population, r, i) == seq[i]
...     for i in range(-len(seq), 0):
...         assert nth_combination(population, r, i) == seq[i]


�
libreftestc	Cs�tttttttttf	}t	j
|�|r|ttd�r|ddl
}dgd}x2tt|��D]"}t	j
|�|j�tj�||<qNWt|�t	jtjt|�dS)N�gettotalrefcountrrW)r9rrmr�r�r�rXrhr�rZrun_unittest�hasattrr��gcrr�Zcollectr�rZrun_doctest�modulesr )�verboseZtest_classesr�Zcountsrrrr�	test_mainz	s


r��__main__T)r�)N)>ZunittestZtestr�	itertoolsrD�decimalrZ	fractionsrr'rrrr1�	functoolsrr�r�ZMAX_Py_ssize_tr�Zminsizer
rrrrrrrrr&r*r+r-r.r0rrdrtZTestCaser9rXrhrmrurvrxryrr{r|r}r~rr�r�r�Zcpython_onlyr�r�Z__test__r�r rrrr�<module>s�
xn*e
	
	
[
_



Youez - 2016 - github.com/yon3zu
LinuXploit