Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_itertools.cpython-39.pyc

a

��gޕ�@svddlZddlmZddlTddlZddlmZddlmZddl	Z	ddl
Z
ddlZddlZddl
mZddlZddlZddlZddlZejZedZdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�d�Zdd�Zdd�Z dd�Z!d 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�Z0Gd8d9�d9�Z1Gd:d;�d;�Z2Gd<d=�d=�Z3Gd>d?�d?�Z4d@dA�Z5GdBdC�dCej(�Z6GdDdE�dEej(�Z7GdFdG�dGej(�Z8GdHdI�dIej(�Z9ej:GdJdK�dKej(��Z;dLZ<dMe<iZ=dSdNdO�Z>e?dPk�rre>dQdR�dS)T�N)�support)�*)�Decimal)�Fraction)�reduce�cGstt|��S�N)�list�zip��args�r
�//usr/local/lib/python3.9/test/test_itertools.py�lzipsrcCsd|S)zTest function of one argument�r
��xr
r
r�oneargsrcGst�dS)z"Test function that raises an errorN)�
ValueErrorrr
r
r�errfuncsrccsdD]
}|VqdS)zNon-restartable source sequence�rrrNr
��ir
r
r�gen3srcCs|ddkS)�Test predicaterrr
rr
r
r�isEven$srcCs|ddkS)rrrr
rr
r
r�isOdd(srcGs|Srr
rr
r
r�tupleize,srccst|�D]
}|VqdSr��range��nrr
r
r�irange/sr"c@s eZdZdZdd�Zdd�ZdS)�StopNowz"Class emulating an empty iterable.cCs|Srr
��selfr
r
r�__iter__5szStopNow.__iter__cCst�dSr��
StopIterationr$r
r
r�__next__7szStopNow.__next__N)�__name__�
__module__�__qualname__�__doc__r&r)r
r
r
rr#3sr#cCstt||��S)zHConvenience function for partially consuming a long of infinite iterable�r	�islice)r!�seqr
r
r�take:sr1cCsttj|d�S�Nr)r�operator�mul��iterabler
r
r�prod>sr7cCsttd|d��S)Z	Factorialr)r7r�r!r
r
r�factAsr9cCs|dS�Nrr
��rr
r
r�testRFsr=cCs|dS�Nrr
r;r
r
r�testR2Isr?cCs|dkS)N�
r
rr
r
r�undertenLsrAcCsg|]}|fdd��qS)cSst�t�||��Sr)�pickle�loads�dumps)�s�protor
r
r�<lambda>O�z<listcomp>.<lambda>r
)�.0rFr
r
r�
<listcomp>Os�rJc@s(eZdZdodd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	e
jdd��Ze
�
d�dd��Zdd�Ze
jdd��Ze
�
d�dd��Zdd�Ze
jdd ��Ze
�
d�d!d"��Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Ze
�
d�d7d8��Zd9d:�Z e
�
d�d;d<��Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%e
jdEdF��Z&e
�
d�dGdH��Z'dIdJ�Z(dKdL�Z)dMdN�Z*dOdP�Z+dQdR�Z,dSdT�Z-dUdV�Z.dWdX�Z/dYdZ�Z0d[d\�Z1d]d^�Z2d_d`�Z3dadb�Z4dcdd�Z5e
j6dedf��Z7e
j6dgdh��Z8e
j6didj��Z9e
j6dkdl��Z:e
j6dmdn��Z;dS)p�TestBasicOps�rNcsd��fdd�	�t�||�}t�|�}|�t|�t|���|��|�}}	|�||	�|rp�|�}
|�||
�t�|�}d}z"t|�D]}
t|�|d7}q�Wnty�Yn0t�||�}t�|�}�|��|�}}	|�||	�|�r
�||d��}
|�||
�dS)zITest that an iterator is the same after pickling, also when part-consumedrcs\�dkrtd��t|t�r|Sztt|���}WntyF|YS0��fdd�|D�S)Nr@zinfinite recursion encounteredcsg|]}�|�d��qS)rr
�rI�e)�expandrr
rrJ`rHz;TestBasicOps.pickletest.<locals>.expand.<locals>.<listcomp>)�RuntimeError�
isinstance�strr	r/�	TypeError)�itr�l�rO�stoprrrOVs

z'TestBasicOps.pickletest.<locals>.expandrN)r)rBrDrC�assertEqual�typer�nextr()r%�protocolrTrWr1�compare�dumpZi2�a�b�cZi3ZtookrZi4r
rVr�
pickletestTs0



zTestBasicOps.pickletestc	Csx|�tttd���gd��|�tttd�d��gd��ttttfD]0}|�ttt|td����tt|gd����qF|�ttd��gd��|�ttg��g�|�ttdg��dg�|�	t
ttd�dd�|�	t
t�|j	t
ttd�d	�|�	t
ttd
gg��gd�}|�tt|t��gd��|�tt|t��gd
��|�tt|t
j��gd��|�	t
��tt|t��Wd�n1�s�0Yttjd
�D]2}|�|ttd���|�|ttd�dd���q�|�ttgd�dd��gd��|�ttgd�dd��gd��|�ttgdd��dg�|�	t
��"ttddgd��Wd�n1�sj0YdS)Nr@)
rr��r@����$�-r5�abc)r^�abri��rcrr)
r��	rlrkrrbrLrrc)
rrrrrrrrrr)
rrmrnrnrnrnrnrnrnrn)
r��i�i�rrrrr)�initial)r@rlr)r@rdro�d)rr�n�s�t�)rXr	�
accumulater�int�complexrr�map�assertRaisesrS�min�maxr3r4�chrrB�HIGHEST_PROTOCOLra)r%�typrErFr
r
r�test_accumulate}sL������.  zTestBasicOps.test_accumulatecCs�dd�}t|fD]z}|�t|dd��td��|�t|d��td��|�t|d��g�|�td|dd��td��|�tt|d	d
��qdS)Ncws|D]}|D]
}|VqqdS)zPure python version in the docsNr
)�	iterablesrT�elementr
r
r�chain2�sz'TestBasicOps.test_chain.<locals>.chain2ri�def�abcdef�rL�abcdrrb)�chainrXr	r1r{rS)r%r�r`r
r
r�
test_chain�szTestBasicOps.test_chaincCs�|�tt�ddg��td��|�tt�dg��td��|�tt�dg��g�|�tdt�ddg��td��|�ttt�ddg��dS)	Nrir�r�r�rLr�rrb)rXr	r��
from_iterabler1r{rSr$r
r
r�test_chain_from_iterable�s
 z%TestBasicOps.test_chain_from_iterablec	Cs�tjgtD]�}tdd�}|�t||��td��|�t|�d�|�t||��td��|�t|td���g�|�td|tdd���td��|�t	t|td	d
���qt
tjd�D]}|j
|tdd�td�d�q�dS)
Nrir�r�r^Zbcdefr�rLr�rrbr�r\)�copy�deepcopy�
picklecopiersr�rXr	rZr1r{rSrrBrra)r%ZoperrTrFr
r
r�test_chain_reducible�s
 z!TestBasicOps.test_chain_reduciblecCs�|�tt�jd�|�tt�jg�|�tt�jd�|�tt�jgf�|�tt�jtg�gf�t�}|�tddg�f�|�t|�gd��t�}|�tddg�tdg�f�|�t|�gd��dS)Nr
rrir�)r^r_r`�drN�f�ghi)r�r^r_r`r�rNr�)r{rSr��__setstate__�iterrXr	�r%rTr
r
r�test_chain_setstate�sz TestBasicOps.test_chain_setstatec
	s�|�ttd�|�ttddd�|�ttd�|�ttdd�dd�gtD]�}|�t|tdd���g�|�t|tdd���gd	��tdd�}t|�|�t||��gd
��|�t|ttd�d���gd
��ttd�d�}t|�|�t||��gd��qLdd�}dd�}dd�}td�D�]�}dd�t|�D��t|d�D�]Z}tt�|��}|�t	|�||k�rtdnt
|�t
|�t
||��|�t	|�t	t|���|�|t|��|D]x�|�t	��|�|�t	t���|�|�t��t���|�
t�fdd��D���|�t���fdd��D���q�|�|t|�|���|�|t|�|���|�|t|�|���ttjd�D]}	|�|	t�|���q��qH�q$dS)Nrirr���cSs|Srr
�r^r
r
rrG�rHz0TestBasicOps.test_combinations.<locals>.<lambda>� �ABCD���A�B�r��C�r��D�r�r��r�r��r�r�)r�r�r�r�r�rLrb�r�rrrb�rrrb�rrrb)r�r�r�c3s�t|��t��}||krdStt|��}t�fdd�|D��Vtt|��D]}|||||krLqnqLdS||d7<t|d|�D]}||dd||<q�t�fdd�|D��Vq@dS)�%Pure python version shown in the docsNc3s|]}�|VqdSrr
�rIr��poolr
r�	<genexpr>�rHzHTestBasicOps.test_combinations.<locals>.combinations1.<locals>.<genexpr>rc3s|]}�|VqdSrr
r�r�r
rr��rH��tuple�lenr	r�reversed)r6r<r!�indicesr�jr
r�r�
combinations1�sz5TestBasicOps.test_combinations.<locals>.combinations1c3sPt|��t��}tt|�|�D],}t|�t|�krt�fdd�|D��VqdS)r�c3s|]}�|VqdSrr
r�r�r
rr�rHzHTestBasicOps.test_combinations.<locals>.combinations2.<locals>.<genexpr>N)r�r��permutationsr�sortedr	�r6r<r!r�r
r�r�
combinations2�s
z5TestBasicOps.test_combinations.<locals>.combinations2c3sPt|��t��}tt|�|�D],}tt|��|krt�fdd�|D��VqdS)zPure python version from cwr()c3s|]}�|VqdSrr
r�r�r
rr�	rHzHTestBasicOps.test_combinations.<locals>.combinations3.<locals>.<genexpr>N)r�r��combinations_with_replacementr�setr�r
r�r�
combinations3s
z5TestBasicOps.test_combinations.<locals>.combinations3rkcSsg|]}d|d�qS�rl�r
�rIrr
r
rrJrHz2TestBasicOps.test_combinations.<locals>.<listcomp>rc3s|]}|�vVqdSrr
rM��valuesr
rr�rHz1TestBasicOps.test_combinations.<locals>.<genexpr>csg|]}|�vr|�qSr
r
rM�r`r
rrJrH)r{rS�combinationsrr�rXr	rZrr�r9r�r��
assertTrue�allrBrra)
r%�op�testIntermediater�r�r�r!r<�resultrFr
�r`r�r�test_combinations�sZ�
���6
�zTestBasicOps.test_combinationscCs<|�ttf��tdd�Wd�n1s.0YdS)N�AAi )r{�
OverflowError�MemoryErrorr�r$r
r
r�test_combinations_overflow sz'TestBasicOps.test_combinations_overflowz"tuple reuse is specific to CPythonc
CsH|�tttttdd����d�|�ttttttdd�����d�dS�N�abcderbr)rXr�r�rz�idr��assertNotEqualr	r$r
r
r�test_combinations_tuple_reuse&s z*TestBasicOps.test_combinations_tuple_reusec
	sft}|�t|d�|�t|ddd�|�t|d�|�t|dd�dd�gtD]L}|�t||dd���gd��|dd�}t|�|�t||��gd	��qPd
d�}dd
�}dd�}td�D�]�}dd�t|�D��t|d�D�]z}t|�|��}	|�t	|	�|||��|�t	|	�t	t
|	���|�|	t|	��tt�|��}
|dk�sV|dk�rd|�|	|
�n|�
t
|	�t
|
�k�|	D]��|�t	��|�dd�t��D�}|�t	|�t	t
|���|�t��t���|�
t�fdd��D���|�|�fdd��D���q~|�|	t|�|���|�|	t|�|���ttjd�D]}|�||�|���qDq�q�dS)Nrirrr�cSs|Srr
r�r
r
rrG2rHzATestBasicOps.test_combinations_with_replacement.<locals>.<lambda>�ABC�)r�r�r�r��r�r�r��r�r�)r�r�r�r�r�c3s�t|��t��}|s|rdSdg|}t�fdd�|D��Vtt|��D]}|||dkrJqhqJdS||dg||||d�<t�fdd�|D��Vq>dS)r�Nrc3s|]}�|VqdSrr
r�r�r
rr�CrHzPTestBasicOps.test_combinations_with_replacement.<locals>.cwr1.<locals>.<genexpr>rc3s|]}�|VqdSrr
r�r�r
rr�KrH)r�r�r�r)r6r<r!r�rr
r�r�cwr1;s
z=TestBasicOps.test_combinations_with_replacement.<locals>.cwr1c3sRt|��t��}tt|�|d�D],}t|�t|�kr t�fdd�|D��Vq dS)r���repeatc3s|]}�|VqdSrr
r�r�r
rr�SrHzPTestBasicOps.test_combinations_with_replacement.<locals>.cwr2.<locals>.<genexpr>N)r�r��productrr�r	r�r
r�r�cwr2Ms
z=TestBasicOps.test_combinations_with_replacement.<locals>.cwr2cSs4|s|rdSdSt||d�t|�t|d�S�Nrr)r9)r!r<r
r
r�numcombsUszATestBasicOps.test_combinations_with_replacement.<locals>.numcombsrkcSsg|]}d|d�qSr�r
r�r
r
rrJ[rHzCTestBasicOps.test_combinations_with_replacement.<locals>.<listcomp>rcSsg|]\}}|�qSr
r
)rI�k�vr
r
rrJkrHc3s|]}|�vVqdSrr
rMr�r
rr�nrHzBTestBasicOps.test_combinations_with_replacement.<locals>.<genexpr>csg|]}|�vr|�qSr
r
rMr�r
rrJprH)r�r{rSrr�rXr	rZrr�r�r�r�r��groupbyr�rBrra)
r%�cwrr�r�r�r�r�r!r<r�Z
regular_combsZnorunsrFr
r�r�"test_combinations_with_replacement+sR�
��z/TestBasicOps.test_combinations_with_replacementcCs<|�ttf��tdd�Wd�n1s.0YdS)Nr��@)r{r�r�r�r$r
r
r�+test_combinations_with_replacement_overflowwsz8TestBasicOps.test_combinations_with_replacement_overflowc
CsLt}|�tttt|dd����d�|�ttttt|dd�����d�dSr�)r�rXr�r�rzr�r�r	)r%r�r
r
r�.test_combinations_with_replacement_tuple_reuse}s z;TestBasicOps.test_combinations_with_replacement_tuple_reusec	s|�tt�|�ttddd�|�ttd�|�ttdd�|�ttdd��g�|�ttdd�|�tttd�d��gd��dd	d
�}ddd�}td
�D�]`}dd�t|�D��t|d�D�]:}tt�|��}|�t|�||kr�dnt|�t||��|�t|�tt	|���|�|t
|��|D]F}|�t|�|�|�tt	|��|�|�t�fdd�|D����q,|�|t|�|���|�|t|�|���||k�r�|�|tt�d���|�|tt����tt
jd�D]}|�|t�|���q�q�q�dS)Nrirrr�r�rErb)�rr�rr�rr�rr)rr)rrc3s:t|��t��}|dur|n|}||kr,dStt|��}tt||d|d��ddd�}t�fdd�|d|�D��V|�r6tt|��D]�}||d8<||dkr�||dd�|||d�||d�<||||<q�||}||||||<||<t�fdd�|d|�D��Vq|q�dSq|dS)r�Nr���c3s|]}�|VqdSrr
r�r�r
rr��rHzHTestBasicOps.test_permutations.<locals>.permutations1.<locals>.<genexpr>rc3s|]}�|VqdSrr
r�r�r
rr��rHr�)r6r<r!r�Zcyclesrr�r
r�r�
permutations1�s&$ ( z5TestBasicOps.test_permutations.<locals>.permutations1c3sbt|��t��}|dur|n|}tt|�|d�D],}tt|��|kr0t�fdd�|D��Vq0dS)r�Nr�c3s|]}�|VqdSrr
r�r�r
rr��rHzHTestBasicOps.test_permutations.<locals>.permutations2.<locals>.<genexpr>)r�r�r�rr�r�r
r�r�
permutations2�sz5TestBasicOps.test_permutations.<locals>.permutations2rkcSsg|]}d|d�qSr�r
r�r
r
rrJ�rHz2TestBasicOps.test_permutations.<locals>.<listcomp>rc3s|]}|�vVqdSrr
rMr�r
rr��rHz1TestBasicOps.test_permutations.<locals>.<genexpr>)N)N)r{rSr�rrXr	rr�r9r�r�r�r�rBrra)r%r�r�r!r<r��prFr
r�r�test_permutations�s:�

	, 
zTestBasicOps.test_permutationscCs<|�ttf��tdd�Wd�n1s.0YdS)Nr�r�)r{r�r�r�r$r
r
r�test_permutations_overflow�sz'TestBasicOps.test_permutations_overflowc
CsH|�tttttdd����d�|�ttttttdd�����d�dSr�)rXr�r�rzr�r�r�r	r$r
r
r�test_permutations_tuple_reuse�s z*TestBasicOps.test_permutations_tuple_reusec	std�D�]}dd|�}td�D�]�tt|�d��}tt|���}tt|���}tt|���}|�t|�|��|�t|�|r�t|�d�t��t|d�n��|�t|��|kr�dnt|�t|���|�t|��|kr�dnt|�t��t|���|�|t	t
|���|�|t	t
|���|�|t	t
|���|�|t	t
|���|�|dd�|D��|�|�fd	d�|D��|�|d
d�|D��|�|�fdd�|D��|�|ttt
|�j|���|�|ttt
|�j|���|�|t	t
|�t
|�@��q"qdS)Nrc�ABCDEFGrmr�rrcSs g|]}t|�t|�kr|�qSr
�r�r	�rI�tr
r
rrJ�rHz3TestBasicOps.test_combinatorics.<locals>.<listcomp>cs g|]}tt|���kr|�qSr
�r�r�r�r;r
rrJ�rHcSs g|]}t|�t|�kr|�qSr
r�r�r
r
rrJ�rHcs g|]}tt|���kr|�qSr
r�r�r;r
rrJ�rH)
rr	r�r�r�r�rXr�r9r�r��filter�__contains__)r%r!rEr7r��perm�combr
r;r�test_combinatorics�s,:,4zTestBasicOps.test_combinatoricsc
Cs0|�ttdgd�d��td��|�ttdgd���td��|�ttdgd���td��|�ttdgd���td��|�ttdgd���td	��|�ttd
gd���td��d
}t�ttd�|��}t�td��}|�tt||��gd�|�|�ttdtd��|�tttd�d�|�tttd��|�tttd�d�dd�dd�gt	D]�}dgd�ddfdgd�ddfdgd�ddfdgd�d	dfd
gd�ddffD]|\}}}}|�t|t||d���t|��|�t|t||���t|��t||�}|�r�t
|�|�t||��t|���q��q\dS)N�ABCDEF�rrrrrr)�data�	selectors�ACEF)rrrrrrr�)rrrrrr�rrrZACr�)rrrrrrZBC�'rcr��rrbrlcSs
t�|�Sr)r�r�r
r
rrG�rHz,TestBasicOps.test_compress.<locals>.<lambda>cSs
t�|�Sr)r�r�r�r
r
rrG�rHZCEFZBCDEFr�)rXr	�compressr�r�r�rr{rSr�rZ)r%r!rrr�Zresult1Zresult2r�r
r
r�
test_compress�s6 � 
zTestBasicOps.test_compressc	CsZ|�tdt��gd��|�tdtd��gd��|�tdtdtd���ddg�|�tdtdtd���d	d
g�|�tdtdtd���dd
g�|�ttddd�|�ttd�|�tdttd��tt	tdtd���|�tdttd��tt	tdtd���|�tdtd��gd��|�tdtd��gd��|�tdtt
d���t
d�t
d�t
d�g�|�tdttdd���tdd�tdd�tdd�g�dd>}|�tdt|��||d|dg�td�}|�t|�d�t
|�|�t|�d�td�}|�t|�d�t
|�|�t
|�d �|�ttd!��d"�|�ttd#��d$�|�tt
td#���t�tjdtjdd%dd&dtjdtjdfD](}tt|��}d'�|�}|�||��q�ddtdtdfD]`}t|�}|�t
t�|��|�|�t
t�|��|�t	tjd�D]}|�|t|���q$�q�tdtd�t��dS)(Nri��r^r�r_r�r`rrb)�r^rb�r_rL)r`rlrrr
r�)r^r�)r_r���)r^r)r_r�rLr^r@rl�
@)rg@g@�
@�)ry@��@��1.1z2.1z3.1rmr��zcount(3)zcount(4)���z	count(-9)i����g�$@zcount(10.25)g$@zcount(10.0)���r�	count(%r))rXr�countr1r
r{rS�maxsizer	rrr�reprrZrY�float�sys�__mod__r�r�rBrra�exc_info)r%�BIGINTr`r�r1�r2�valuerFr
r
r�
test_countsZ   ����$4
zTestBasicOps.test_countcCsX|�tdtdd��gd��|�tdtddd��gd��|�tdtdd��gd��|�ttd	d
�|�tdtdd��gd��|�tdtdd
��gd��|�tdtdd��gd��|�tdttdd��tdttdtdd���|�tdttdd��tdttdtdd���|�tdtdtd��ttdddtdtd���|�tdtdd��gd��|�tdtdd��gd��|�tdtt	d�t	d���t	d�t	d�t	d�g�|�tdtt
dd�t
d
d���t
dd�t
dd�t
dd�g�d
d>}|�tdt|d��d|d|g�|�ttdtdd ���tgd!���tdd�}|�t|�d"�t|�|�t|�d#�td$d�}|�t|�d%�t|�|�t|�d%�td$d&�}|�t|�d'�t|�|�t|�d(�|�t|�d(�|�ttd)d��d*�|�ttd)d
��d+�|�ttd)d,��d-�|�ttdd,��d.�tdd,�}|�t
t|��t�|�t
t|��t�tjdtjdd/dddtjdtjdfD]�}tjdtjdd/ddd
dtjdtjdf	D]h}tt||��}|d
k�rd0|}nd1||f}|�||�ttjd
�D]}|�|t||���q2�q�q�dS)2Nrirrb)�r^r)r_rl)r`rm)�start�stepr�)r%)r	)r_r�)r`r�r^r_r)r#)r_rrr)r#)r_rb)r`rLrvrdrrr@rlg�?)rrg@r)rry!@ �rz.1z1.2z1.3rk�rerg@)r@g)@g.@zcount(3, 5)zcount(8, 5)rzcount(-9, 0)rz
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)rrz
count(%r, %r))rXrrr{rSr1rrr	rrrrZrYrxrrrBrra)r%rr`rr�rr rFr
r
r�test_count_with_stride?sp��28���"$



46

z#TestBasicOps.test_count_with_stridecs�|�tdtd��td��|�ttd��g�|�tt�|�ttd�|�tttt��d��gd��td��|�t��d�|�tdt	�
���td��ttj
d	�D]d}|�tdt�t��|���td��t��|�tdt�t��|���td
��t��t��q�ttj
d	�D]}|�|td���qttj
d	�D]�}td�}t|���fdd
�td�D�}t��|�}t�|�}|�td|�td��td�}t|���fdd
�td�D�}t��|�}t�|�}|�td|�td���qDdS)Nr@riZ
abcabcabcar�rl)
rrrrrrrrrrr^Z
bcabcabcabrZ
cabcabcabcr�csg|]}t���qSr
�rZr�r�r
rrJ�rHz+TestBasicOps.test_cycle.<locals>.<listcomp>rrvZcdeabcdeabcdeabcdeabcsg|]}t���qSr
r(r�r�r
rrJ�rHrk)rXr1�cycler	r{rSr/rrZr�r�rrBrrCrDrar�)r%rFrT�_r�r�r
r�r�
test_cyclevsB ��


zTestBasicOps.test_cyclecCs^td�}|�td�df�|�td|�td��td�}|�td�df�|�td|�td��|�t��&td��td�dg�Wd�n1s�0Y|�t��*td�}|�td�df�Wd�n1s�0Ytd|�|�t��&td��td�df�Wd�n1�s&0Y|�ttd	�jd
�|�ttd	�jgf�dS)N�defgrirrvZdefgabcdefgabcdefgab�abcdefgrrr�r
)r)r�r	rXr1r{rSr�)r%r`r
r
r�test_cycle_setstate�s 40
6z TestBasicOps.test_cycle_setstatec
s�|�gttg���|�gttgtd���|�tttdg��|�ttd�|�ttddd�d�gd�}g}t|dd��D],\}}|D]}|�||d�|�|�q�q~|�||�ttj	d	�D]Z}g}t�
t�t|t�|��D],\}}|D]}|�||d�|�|�q�q�|�||�q�g}t|t�D]V\}}t|t
�D]@\}}|D]0}|�||d�|�||d
�|�|��qN�qB�q0|�||�ttj	d	�D]�}g}t�
t�t|t�|��D]d\}}t�
t�t|t
�|��D]@\}}|D]0}|�||d�|�||d
�|�|��q�q�q�|�||��q�dd�t|t�D�}	td
d�|D��}
|�t|	�|
�|�t|	�t|
��ttdtd���}t|t�}t|�\}}
t|�\}}t|�\}}|�t|
�g�|�t|�g�|�t|�d�t|�|�t|�g�ttj	d	�D]J}t|t�}t|�\}}t|�t|�|�tt�
t�||���g��qd}dd�tt|��D�}|�|gd��dd�tt|��D�}|�|gd��dd�tt|��D�}|�|gd��tdd�tt|��D�dd�dd�}|�|gd��Gdd�dt��d(�fdd �	}dtfd!d"�}|��||d��|��||d	��G�fd#d$�d$�}|�|�dg}|j�||td%�|��||���fd&d'��d�_|��|dg��d	�_|��|ddg��dS))N��keyricSs|Srr
rr
r
rrG�rHz+TestBasicOps.test_groupby.<locals>.<lambda>r@))rr@rv)r�re)rr�re)r�
re)r��)rrdr4)rbro�)rbr&r5cSs|dSr:r
r;r
r
rrG�rHrrrcSsg|]\}}|�qSr
r
�rIr��gr
r
rrJ�rHz-TestBasicOps.test_groupby.<locals>.<listcomp>cSsg|]}|d�qS)rr
)rIr<r
r
rrJ�rHZ	AABBBAAAArn)r�rlZabracadabracSsg|]\}}|�qSr
r
r6r
r
rrJrH)r^r_r`r�r<cSs$g|]\}}tt|dd��r|�qSr�r.r6r
r
rrJrH)r^r_r<cSs g|]\}}tt|��|f�qSr
�r�r	r6r
r
rrJrH)�rlr^�rr_)rr`)rr��rr<cSs g|]\}}tt|��|f�qSr
r8r6r
r
rrJrHT)�reverserb)r9r;r:c@seZdZdS)z0TestBasicOps.test_groupby.<locals>.ExpectedErrorN)r*r+r,r
r
r
r�
ExpectedErrorsr=c3st|�D]
}dVq��dS)NZyorr �r=r
r�
delayed_raise!sz0TestBasicOps.test_groupby.<locals>.delayed_raisecs�fdd�t||�D�S)Ncsg|]\}}�|��qSr
r
r6��funcr
rrJ&rHz;TestBasicOps.test_groupby.<locals>.gulp.<locals>.<listcomp>)r�)r6ZkeyprAr
r@r�gulp%sz'TestBasicOps.test_groupby.<locals>.gulpcseZdZ�fdd�ZdS)z+TestBasicOps.test_groupby.<locals>.DummyCmpcs��dSrr
)r%�dstr>r
r�__eq__/sz2TestBasicOps.test_groupby.<locals>.DummyCmp.__eq__N)r*r+r,rDr
r>r
r�DummyCmp.srEr@cs$�jdkr�jd8_|S��dSr�)�skip)�obj�r=�keyfuncr
rrI9s
z*TestBasicOps.test_groupby.<locals>.keyfunc)r)rXr	r�r�r{rS�appendrrBrrCrDr=r?r�r�r
rZr��	ExceptionrF)r%rE�dupr�r7�elemrFZikZig�keysZexpectedkeysrTr*Zg1Zg2Zg3r<r?rBrEr
rHr�test_groupby�s�   

"&zTestBasicOps.test_groupbyc
Cs�|�ttttd���gd��|�ttdgd���ddg�|�tttgd���ddg�|�tdttt���gd��|�t	t�|�t	tdd	��|�t	td
d	�td�d�|�t	ttd�|�t	t
ttd�td���gd�}tttd��}|�tt�|��|�tttd��}|�tt�|��|�tt
jd�D]`}tttd��}|�tt
�t
�||���|�t
|�|�tt
�t
�||���|dd���q:tt
jd�D] }tttd��}|�||��q�dS)
Nrc)rrrL�rrrrrrrrL)rrrLrccSs|Srr
rr
r
rrGLrHz*TestBasicOps.test_filter.<locals>.<lambda>cSs|Srr
rr
r
rrGMrHrkrb)rXr	r�rr�boolr1rr{rSrZr�r�rBrrCrDra�r%�ansr`rFr
r
r�test_filterFs,*zTestBasicOps.test_filtercCs
|�ttttd���gd��|�ttdgd���gd��|�tttgd���gd��|�tdttt���gd��|�t	t�|�t	tdd��|�t	td	d�td�d
�|�t	ttd�|�t	t
ttd�td���ttjd�D]}|�
|tttd���q�dS)
NrcrrP�rrrrL)rrbrlrkcSs|Srr
rr
r
rrGgrHz/TestBasicOps.test_filterfalse.<locals>.<lambda>cSs|Srr
rr
r
rrGhrHrkrbr)rXr	�filterfalserrrQr1rr{rSrZrBrra�r%rFr
r
r�test_filterfalseaszTestBasicOps.test_filterfalsecCs(dd�tdt��D�}|�|gd��|�ttdtd���tdtd���|�ttdtd���tdtd���|�tdtdt���tdtd���|�ttd��td��|�tt��t��|�ttd�|�tttd�d�|�dd�tdd	�D�tdd	��|�d
d�tdd	�D�tdd	��dS)NcSsg|]\}}||f�qSr
r
�rIr�yr
r
rrJprHz)TestBasicOps.test_zip.<locals>.<listcomp>rirrcr�rbcSsg|]}tt|���qSr
�r�r	�rIZpairr
r
rrJyrHr�cSsg|]}|�qSr
r
r\r
r
rrJ{rH)	r
rrXr	rrr1r{rS)r%rSr
r
r�test_zipns$$$��zTestBasicOps.test_zipc	Cs~ttttdd���}|�t|�t|��tttttdd����}|�tt�	|��t|��dd�t
�
tdt���D�}|�|gd��dd�t
�tdt���D�}|�|gd��t
tjd�D]8}dd�t�t�tdt��|��D�}|�|gd��q�t
tjd�D]F}tdt��}t|�d	d�t�t�||��D�}|�|d
dg��qt
tjd�D]}|�|tdt����q^dS)Nrir�cSsg|]\}}||f�qSr
r
rYr
r
rrJ�rHz5TestBasicOps.test_zip_tuple_reuse.<locals>.<listcomp>rcSsg|]\}}||f�qSr
r
rYr
r
rrJ�rHrcSsg|]\}}||f�qSr
r
rYr
r
rrJ�rHcSsg|]\}}||f�qSr
r
rYr
r
rrJ�rHr
r)r	rzr�r
rXr|r}r��dict�fromkeysr�rr�rrBrrCrDrZra)r%�idsrSrFr�r
r
r�test_zip_tuple_reuse~s$$z!TestBasicOps.test_zip_tuple_reusecsXdtd�gtd�dgtd�tdd�tdd�gtd�td�tdd�td	�td
�gtd�td�tdd�td	�td
�td�gfD]���fdd�tttt����D�}|�tt���|�|�tt�ii���|�d
d�|D�}|�tt�itdd����|�qz|�tdtdt	���tt
dtd����|�tt��tt
���|�ttg��tt
g���|�ttd��tt
d���|�ttdii���tt
td�dgd���|�ttd�|�tttd�d�dD]>}zt
|t�t��Wnt�y�Yn0|�d|��q�|�dd�tdd�D�tt
dd���|�dd�tdd�D�tt
dd���dS)Nrircr��i4i�i�ri�i�cs"g|]�t�fdd��D���qS)cs$g|]}�t|�kr|�nd�qSr�r�)rI�argrr
rrJ�rHz;TestBasicOps.test_ziplongest.<locals>.<listcomp>.<listcomp>�r�)rIrrrrJ�s�z0TestBasicOps.test_ziplongest.<locals>.<listcomp>cSsg|]}tdd�|D���qS)css|]}|durdp|VqdS)N�Xr
rMr
r
rr��rHz:TestBasicOps.test_ziplongest.<locals>.<listcomp>.<genexpr>rer�r
r
rrJ�rHrf��	fillvaluerbr�r,)zzip_longest('abc', fv=1)z3zip_longest('abc', fillvalue=1, bogus_keyword=None)zDid not raise Type in:  cSsg|]}tt|���qSr
r[r\r
r
rrJ�rHr�cSsg|]}|�qSr
r
r\r
r
rrJ�rH)rir,)rr}rzr�rXr	�zip_longestr^r1rr
r{rS�eval�globals�localsZfail)r%�targetZstmtr
rr�test_ziplongest�sD

"(�
�"(���zTestBasicOps.test_ziplongestcCs^ttttdd���}|�t|�t|��tttttdd����}|�tt�	|��t|��dS)Nrir�)
r	rzr�rirXr|r}r�r^r_)r%r`r
r
r�test_zip_longest_tuple_reuse�sz)TestBasicOps.test_zip_longest_tuple_reusec	Csdttjd�D]P}|�|tdd��|�|tdd��|�|tdddd��|�|tdd��qdS)Nrrir�Zdefghrgr�)rrBrrarirWr
r
r�test_zip_longest_pickling�s
z&TestBasicOps.test_zip_longest_picklingcs^t��G�fdd�d�}|�t��}t|��Wd�n1sB0Y|�|j��dS)NcseZdZ�fdd�ZdS)z?TestBasicOps.test_zip_longest_bad_iterable.<locals>.BadIterablecs��dSrr
r$��	exceptionr
rr&�szHTestBasicOps.test_zip_longest_bad_iterable.<locals>.BadIterable.__iter__N)r*r+r,r&r
rqr
r�BadIterable�srs)rSr{riZassertIsrr)r%rs�cmr
rqr�test_zip_longest_bad_iterable�s
(z*TestBasicOps.test_zip_longest_bad_iterablecCs�Gdd�d�}|ddt�}|ddt�}dd�}|�|||�gd	��|ddt�}|ddt�}t||d
d�}|�t|�d�|�t|�d�|�t|�d�|�tt|�dS)
Nc@s$eZdZdd�Zdd�Zdd�ZdS)z,TestBasicOps.test_bug_7244.<locals>.RepeatercSs||_t|�|_||_dSr)�orxr�rN)r%rvr�rNr
r
r�__init__�s
z5TestBasicOps.test_bug_7244.<locals>.Repeater.__init__cSs|Srr
r$r
r
rr&�sz5TestBasicOps.test_bug_7244.<locals>.Repeater.__iter__cSs(|jdkr|jd8_|jS|j�dSr�)r�rvrNr$r
r
rr)�s
z5TestBasicOps.test_bug_7244.<locals>.Repeater.__next__N)r*r+r,rwr&r)r
r
r
r�Repeater�srxrrbrrLc	Ssdg}t||dd�D]L\}}t�d��t||f�Wd�n1sF0Y|�||f�q|S)Nrrg�stdout)rirZcaptured_output�printrJ)rr r�rr�r
r
r�run�s*z'TestBasicOps.test_bug_7244.<locals>.run)r�r�r�r�rrgr�)r(rXrPrirZr{)r%rxrr r{rTr
r
r�
test_bug_7244�szTestBasicOps.test_bug_7244cs�gdgfdgddgftd�td�ggd�ftd�td�td�ggftd�td�td�ggftd�td�td�ggffD]V\}}|�tt|��|�td	�D]0}|�tt||��tt|it|d
�����q�qv|�ttttd�gd���d
�|�tttd�d�dd�}dd�}dddtd�td	�tdddd�td�td�t	td��g	�td�D]�}�fdd�tt
�d��D�}tt
t|��}|�ttt|���|�|�tt|��t||���|�tt|��t||���t
t|�}|�ttt|���|��qTdS)Nr
rjr��r_rrb�)rrr�r�r�)rrr�rrLr�rkrci��cs�ttt|��|�dd�}t|�}|dkr4dVdStdd�|D��rJdSdg|}tdd�t||�D��Vtt|��D]h}||t||�dkr�qz||d7<t|d|�D]}d||<q�tdd�t||�D��VqnqzdSqndS)	Nr�rrr
css|]}t|�dkVqdS)rNrc)rIr�r
r
rr�rHz>TestBasicOps.test_product.<locals>.product1.<locals>.<genexpr>css|]\}}||VqdSrr
�rIr�rr
r
rr�rHcss|]\}}||VqdSrr
rr
r
rr�&rH)	r	rzr��getr��anyr
r�r)r�kwds�poolsr!r�rr�r
r
r�product1s$

z+TestBasicOps.test_product.<locals>.product1c?sTttt|��|�dd�}gg}|D]��fdd�|D�}q$|D]}t|�Vq@dS)z Pure python version used in docsr�rcs g|]}�D]}||g�qqSr
r
rYr�r
rrJ0rHz?TestBasicOps.test_product.<locals>.product2.<locals>.<listcomp>N)r	rzr�r�)rr�r�r�r7r
r�r�product2+sz+TestBasicOps.test_product.<locals>.product2r�rir)r^r_r`r-r1r2rrcsg|]}t����qSr
)�random�choice)rIr���argtypesr
rrJ7rHz-TestBasicOps.test_product.<locals>.<listcomp>rl)rrXr	r�r^r�r{rSr�r�r��	randranger7rzr�)r%rr�r<r�r�r�expected_lenr
r�r�test_products6��"	�
zTestBasicOps.test_productcCsF|�ttf��$tdgdddi�Wd�n1s80YdS)Nrjr�r�i)r{r�r�r�r$r
r
r�test_product_overflow?sz"TestBasicOps.test_product_overflowc
CsH|�tttttdd����d�|�ttttttdd�����d�dS)Nrir�r)rXr�r�rzr�r�r�r	r$r
r
r�test_product_tuple_reuseDs z%TestBasicOps.test_product_tuple_reusec	Cs�gdgfdgddgftd�td�ggd�ftd�td�td�ggftd�td�td�ggftd�td�td�ggffD]`\}}|�tt�t|���|�|�tt�t|���|�ttjd	�D]}|�|t|��q�qvdS)
Nr
rjr�r}rrbr~rr)	rrXr	r�r�r�rBrra)r%rr�rFr
r
r�test_product_picklingIs�z"TestBasicOps.test_product_picklingcCsLtdd�}|�d�|�t|�d�tddd�}|�d�|�tt|�dS)Nr�)rb)r�)rrbr
)rrr�)r�r�rXrZr{r()r%r�r
r
r�test_product_issue_25021Xs


z%TestBasicOps.test_product_issue_25021cCs�|�ttddd��gd��|�ttd�td��gd��|�ttdd��gd��|�tdtd��gd��|�ttdd��g�|�ttdd��g�|�tt�|�ttddd�|�ttdd�td	�}|�t|�d
�td	d�}|�t|�d�t|�|�t|�d
�tddd�}|�t	|�d�|�tdt
�
|��td��|�tdt
�|��td��ttj
d�D]}|�|tddd���qtdS)Nr^rb)�object�times)r^r^r^))rr^)rr^)rr^rrrLy�?zrepeat((1+0j))rlzrepeat((1+0j), 5)zrepeat((1+0j), 0)r@rZaar)rXr	r�rrr1r{rSrrZr�r�rBrra)r%r<r`rFr
r
r�test_repeatbs.�
zTestBasicOps.test_repeatcCs`|�ttdd��d�|�ttdd��d�|�ttddd��d�|�ttddd��d�dS)Nr^r�zrepeat('a', 0)r��r�)rXrr�r$r
r
r�test_repeat_with_negative_times|sz,TestBasicOps.test_repeat_with_negative_timesc	Cs�|�tttjtd�tdd���gd��|�tttdtd���gd��|�tttdt���gd��|�tdttdt���d	d
g�|�tttjg��g�|�	t
t�|�	t
ttdtd�td���|�	t
ttj�|�	t
ttdtd���|�	t
tttdgdg��|�	t
tttdgdg��gd�}ttdt��}|�tt�|��|�ttdt��}|�tt�|��|�ttjd�D] }ttdt��}|�||��q�dS)
Nrbrrk�rrrmrirlrrr	r
r@rL)rXr	rzr3�powrrrr1r{rS�negrZrrrr�r�rBrrarRr
r
r�test_map�s6����zTestBasicOps.test_mapc
Cs�|�tttjttd�tdd����gd��|�tdttjtt�td����gd��|�tttjg��g�|�tttjt	ddg�g��dg�|�
ttttjdg��|�
tt�|�
tttjdgd	�|�
tttd
dg��|�
t
tttdg��|�
ttttdg��gd�}ttjttd�tdd���}|�tt�|��|�ttjttd�tdd���}|�tt�|��|�ttjd�D].}ttjttd�tdd���}|�||��q�dS)Nrbrrkr�rLrli�rLrl�extrar@)rXr	�starmapr3r�r
rr1rr�r{rSrZrrrr�r�rBrrarRr
r
r�test_starmap�s,"� �$zTestBasicOps.test_starmapc		CsRdD],}|�tttd�g|�R��tt|���qdD]0\}}|�tttd�g|�R��tt|���q6|�tttd�d��ttd���|�tttd�dd��ttd���|�tttd�ddd��ttd���|�tttd�dd��ttdd���|�tttd�ddd��ttddd���ttd��}|�tt|d��ttd���|�t|�ttdd���ttd��}|�tt|dd��g�|�t|�ttdd���td�}|�tt|�|�tt|dddd�|�tt|d	dd�|�tt|dd	d
�|�tt|ddd
�|�tt|ddd�|�tt|d�|�tt|dd�|�tt|dd�|�tt|ddd�|�tt|ddd�|�tttt	�ddt
���d�t	�}|�tt|ddd
��dg�|�t|�d�dD]�}|�tt�ttd�g|�R���tt|���|�tt�
ttd�g|�R���tt|���ttjd�D]"}|�|ttd�g|�R���qB�q�dd�dD�}t�|�}t|d�}|�|��t|�t��|�|��Gdd�dt�}|�tttd�|d���ttd���|�tttd�|d�|d
���ttdd
���|�tttd�|d�|d
�|d���ttdd
d���dS)N)�r@rvrb�r@rbrv�r@rv)r@r@�r@rb�rvrr)))r@rsrb)r@rrrb))r@rs)r@rr))rs)rrr@rrrbrL���r�rr^�2)r�r�r�r�r�css|]
}|VqdSrr
r�r
r
rr�rHz+TestBasicOps.test_islice.<locals>.<genexpr>r�c@seZdZdd�Zdd�ZdS)z)TestBasicOps.test_islice.<locals>.IntLikecSs
||_dSr��val�r%r�r
r
rrwsz2TestBasicOps.test_islice.<locals>.IntLike.__init__cSs|jSrr�r$r
r
r�	__index__sz3TestBasicOps.test_islice.<locals>.IntLike.__index__N)r*r+r,rwr�r
r
r
r�IntLikesr�rl)rXr	r/rr�r{rSrr�rrrZr�r�rBrra�weakref�refZassertIsNotNoner�
gc_collectZassertIsNoner�)	r%rZtgtargsrTZrar`rF�wrr�r
r
r�test_islice�sv
�
�"$&&*  
� 
�$

&�$�zTestBasicOps.test_islicecCs2gd�}|�ttt|��gd��|�tttg��g�|�tt�|�tttj�|�tttjdgd�|�tttddg��|�t	ttt
dg��ttgd��}|�t|�gd��|�tt|�|�tt
�
tt|���gd��|�tt
�tt|���gd��ttjd�D]}|�|tt|���qdS)	N�rrbrlrvrrLrcrmrr�r�r@)rrrrrr�rrrr)rXr	�	takewhilerAr{rSr3r�rZrrrQr(r�r�rrBrra)r%rr�rFr
r
r�test_takewhiles" �zTestBasicOps.test_takewhilecCsgd�}|�ttt|��gd��|�tttg��g�|�tt�|�tttj�|�tttjdgd�|�tttddg��|�t	ttt
dg��|�tt�tt|���gd��|�tt�tt|���gd��t
tjd�D]}|�|tt|��q�dS)Nr�)rvrrLrcrmr�r�r@r)rXr	�	dropwhilerAr{rSr3r�rZrrr�r�rrBrra)r%rrFr
r
r�test_dropwhile-s �zTestBasicOps.test_dropwhilecCs
d}tg�\}}|�t|�g�|�t|�g�tt|��\}}|�t||�tt|�t|���tt|��\}}|�t|�tt|���|�t|�tt|���tt|��\}}td�D]}|�t|�|�q�~|�t|�tt|���tt|��\}}td�D]}|�t|�|��q~|�t|�ttd|���td�D]�}dg|dg|}t�|�ggf}tt|��}|D] }t||�}	||�	|	��qv|�|dtt|���|�|dtt|����q<|�
tt�|�
ttd�|�
ttddgd�|�
ttddgdd�td	�\}}t|�d
�}
|�t|
�td
��ttd�d�\}}}
td�D]}|�t|�|��qX|�t|�ttd���|�t|
�t|
�gttd���|�t|�ttdd���|�t|
�ttdd���|�
ttd	d�|�
t
tgd
�td�D]P}td	|�}|�t|�t�|�t|�|�|�dd�|D�td	�g|��qtd	�\}}t|�\}
}|�||
u�td	�\}
}t|
�}|�
t|�|�
t|d�||
�}|�t|
�t|�k�o�t|�k�o�td	�kn�ttd��\}}t�|�}|�t|d�t|��~t��|�
tt|d�td	�}ttd��}td	�\}}|�tt�|��|�|�tt�|��|�tttd���\}}|�tt�|��|�|�tt�|��|�td	�\}}td|�td|�|�tt�|��|dd��|�tt�|��|dd��|�t|�|dd��|�t|�|dd��ttd��\}}td|�td|�|�tt�|��|dd��|�tt�|��|dd��|�t|�|dd��|�t|�|dd��td	�\}}|�tt�|��|�|�tt�|��|�|�t|�|�|�t|�|�ttd��\}}|�tt�|��|�|�tt�|��|�|�t|�|�|�t|�|�td	�\}}td|�td|�|�tt�|��|dd��|�tt�|��|dd��|�t|�|dd��|�t|�|dd��ttd��\}}td|�td|�|�tt�|��|dd��|�tt�|��|dd��|�t|�|dd��|�t|�|dd��ttjd�D]F}|�|ttd	���td	�\}}|j|||d�|j|||d��q�dS)N��rrrlrrrbrrrir�rb�invalidr�cSsg|]}t|��qSr
�r	r�r
r
rrJ~rHz)TestBasicOps.test_tee.<locals>.<listcomp>r@�	__class__r�<r�)�teerXr	r"rrrZr��shufflerJr{rSrYrr�r�r�r��proxy�getattrrr��ReferenceErrorr�r1r�rBrrar�)r%r!r^r_rr��orderZlistsZitsr!r`r�r��t1�t2ZtnewZt3r�rSZlong_ansrFr
r
r�test_tee>s� 
 
$<








zTestBasicOps.test_teecCs8ttdd��\}}zt|�~Wn~~�Yn0dS)Ni-1)r�r�r�)r%ZforwardZbackwardr
r
r�test_tee_del_backward�sz"TestBasicOps.test_tee_del_backwardcsXG�fdd�d�}t|��\}�|�td��t|�Wd�n1sJ0YdS)Ncs$eZdZdZdd�Z�fdd�ZdS)z(TestBasicOps.test_tee_reenter.<locals>.ITcSs|Srr
r$r
r
rr&�sz1TestBasicOps.test_tee_reenter.<locals>.I.__iter__cs|j}d|_|rt��SdS�NF)�firstrZ)r%r�r}r
rr)�sz1TestBasicOps.test_tee_reenter.<locals>.I.__next__N)r*r+r,r�r&r)r
r}r
r�I�sr�r�)r��assertRaisesRegexrPrZ)r%r�r^r
r}r�test_tee_reenter�s
zTestBasicOps.test_tee_reentercs�t���t���G��fdd�d�}t|��\}}tjt|gd�}|��zP���|�td��t|�Wd�n1s~0YW��	�|�
�n��	�|�
�0dS)Ncs"eZdZdd�Z��fdd�ZdS)z+TestBasicOps.test_tee_concurrent.<locals>.IcSs|Srr
r$r
r
rr&�sz4TestBasicOps.test_tee_concurrent.<locals>.I.__iter__cs������dSr)r��waitr$�Zfinishr$r
rr)�sz4TestBasicOps.test_tee_concurrent.<locals>.I.__next__N)r*r+r,r&r)r
r�r
rr��sr�)rmrr�)�	threading�Eventr��ThreadrZr$r�r�rPr��join)r%r�r^r_�threadr
r�r�test_tee_concurrent�s(
�z TestBasicOps.test_tee_concurrentcCs$|�ttt��ttttfD]*}|�tt|g��|�tt|t���q|�tttgd��|�tttt�d��t	g�\}}|�tt|�|�tt|�t	t��\}}|�tt|�|�tt|�|�ttt
dd��ttt
tttfD]6}|�tt|dd�g��|�tt|dd�t���q�dS)NrcSs|Srr
rr
r
rrGrHz1TestBasicOps.test_StopIteration.<locals>.<lambda>cSs|Srr
rr
r
rrGrH)r{r(rZr
r�r)r�r#r/r�r�r�rVrzr�r�r�)r%r�r��qr
r
r�test_StopIterations zTestBasicOps.test_StopIterationcCs6tdggd�}t|�t��|�t�t|���dSr2)r�rZ�gc�collectr��
is_trackedr�r
r
r�test_combinations_result_gcsz(TestBasicOps.test_combinations_result_gccCs6tdggd�}t|�t��|�t�t|���dSr2)r�rZr�r�r�r�r�r
r
r�,test_combinations_with_replacement_result_gc%sz9TestBasicOps.test_combinations_with_replacement_result_gccCs6tdggd�}t|�t��|�t�t|���dSr2)r�rZr�r�r�r�r�r
r
r�test_permutations_result_gc-sz(TestBasicOps.test_permutations_result_gccCs4tdgg�}t|�t��|�t�t|���dSr)r�rZr�r�r�r�r�r
r
r�test_product_result_gc5sz#TestBasicOps.test_product_result_gccCs*tgg�}t��|�t�t|���dSr)rir�r�r�r�rZr�r
r
r�test_zip_longest_result_gc=s
z'TestBasicOps.test_zip_longest_result_gc)rLrN)<r*r+r,rar�r�r�r�r�r�rZbigaddrspacetestr�Zimpl_detailr�r�r�r�r�r�r�r�rr"r'r+r.rOrTrXr]rarnrorprur|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��cpython_onlyr�r�r�r�r�r
r
r
rrKRs�
)#

P

L

?

!"07*$

*
(:


^	



rKc@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 |�ttgd���gd��dS�N�rrrbrLrl�rrbrcr@rd)rXr	rwr$r
r
rr�GszTestExamples.test_accumulatec
Cs�gd�}gd�}ttjd�D]h}t|�}|�tt�t�||���|dd��|�t|�d�|�tt�t�||���|dd��qt|�}|�t|�d�|�tt	�
|��|dd��|�tt	�	|��|dd��dS)Nr�r�r)rrBrrwrXr	rCrDrZr�r�)r%rZaccumulatedrFrTr
r
r�test_accumulate_reducibleJs&(z&TestExamples.test_accumulate_reduciblecCs�tgd�tj�}|�t|�d�ttjd�D]*}t�t�	||��}|�t
|�ddg�q.|�t
t�|��ddg�|�t
t�|��ddg�dS)N)NNNrTF)
rwr3�is_rXrZrrBrrCrDr	r�r�)r%rTrFZit_copyr
r
r�test_accumulate_reducible_noneYsz+TestExamples.test_accumulate_reducible_nonecCs|�d�tdd��d�dS�Nr�r�ZDEFr�)rXr�r�r$r
r
rr�cszTestExamples.test_chaincCs |�d�t�ddg��d�dSr�)rXr�r�r�r$r
r
rr�fsz%TestExamples.test_chain_from_iterablecCs<|�ttdd��gd��|�tttd�d��gd��dS)Nr�rr�rLrbr�)rXr	r�rr$r
r
rr�is��zTestExamples.test_combinationscCs|�ttdd��gd��dS)Nr�rr�)rXr	r�r$r
r
rr�os�z/TestExamples.test_combinations_with_replacementcCs"|�ttdgd���td��dS)Nr�r�r)rXr	rr$r
r
rrsszTestExamples.test_compresscCs"|�tttd�d��gd��dS)Nr@rl)r@r1r�r2r3)rXr	r/rr$r
r
rr"vszTestExamples.test_countcCs"|�tttd�d��td��dS)Nr�r�ZABCDABCDABCD)rXr	r/r)r$r
r
rr+yszTestExamples.test_cyclecCs&|�ttdd�gd���gd��dS)NcSs|dkS�Nrlr
rr
r
rrG}rHz-TestExamples.test_dropwhile.<locals>.<lambda>�rrLrcrLr)rcrLr)rXr	r�r$r
r
rr�|szTestExamples.test_dropwhilecCsT|�dd�td�D�td��|�dd�td�D�td�td�td	�td
�g�dS)NcSsg|]\}}|�qSr
r
r6r
r
rrJ�rHz-TestExamples.test_groupby.<locals>.<listcomp>ZAAAABBBCCDAABBBZABCDABcSsg|]\}}t|��qSr
r�r6r
r
rrJ�rHZ
AAAABBBCCDZAAAAZBBBZCCr�)rXr�r	r$r
r
rrOs��zTestExamples.test_groupbycCs&|�ttdd�td���gd��dS)NcSs|dSr>r
rr
r
rrG�rHz*TestExamples.test_filter.<locals>.<lambda>r@)rrbrlrkrn)rXr	r�rr$r
r
rrT�szTestExamples.test_filtercCs&|�ttdd�td���gd��dS)NcSs|dSr>r
rr
r
rrG�rHz/TestExamples.test_filterfalse.<locals>.<lambda>r@)rrrLrcrm)rXr	rVrr$r
r
rrX�szTestExamples.test_filterfalsecCs |�tttdd��gd��dS)N)rrbr@)rlrrb�r�rnr)rXr	rzr�r$r
r
rr��szTestExamples.test_mapcCst|�ttdd��td��|�ttddd��td��|�ttddd��td��|�ttdddd��td��dS)	Nr�r�ABrL�CD�CDEFGr�ACEG)rXr	r/r$r
r
rr��szTestExamples.test_islicecCs|�ttdd��ddg�dS)Nr��xy�r�r�r�rZ)rXr	r
r$r
r
rr]�szTestExamples.test_zipcCs"|�ttdddd��gd��dS)Nr�r��-rg)r�r�)r�r�)r�r�)rXr	rir$r
r
r�test_zip_longest�s�zTestExamples.test_zip_longestcCsD|�ttdd��tttd�����|�tttd���gd��dS)Nr�rz#AB AC AD BA BC BD CA CB CD DA DB DCrb)r)rrr)rrr)rrr)rrr)rrr)rXr	r�rzr��splitrr$r
r
rr��s��zTestExamples.test_permutationscCsH|�ttdd��tttd�����|�tttd�dd��gd��dS)Nr�r�zAx Ay Bx By Cx Cy Dx Dyrrbr�)rU)rrr)rrr)rrr)rrrr)rrrr�)rXr	r�rzr�r�rr$r
r
rr��s��zTestExamples.test_productcCs|�ttdd��gd��dS)Nr@rb)r@r@r@)rXr	r�r$r
r
rr��szTestExamples.test_repeatcCs"|�tttgd���gd��dS)N))rrl)rbrr�r�)rXr	r�r�r$r
r
r�test_stapmap�s�zTestExamples.test_stapmapcCs&|�ttdd�gd���ddg�dS)NcSs|dkSr�r
rr
r
rrG�rHz-TestExamples.test_takewhile.<locals>.<lambda>r�rrL)rXr	r�r$r
r
rr��szTestExamples.test_takewhileN)r*r+r,r�r�r�r�r�r�r�rr"r+r�rOrTrXr�r�r]r�r�r�r�r�r�r
r
r
rr�Es.
r�c@s eZdZedd��Zdd�ZdS)�TestPurePythonRoughEquivalentsc
gs�t|�}|jpd|jptj|jp"d}}}tt|||��}zt|�}Wn,t	ytt
t|�|�D]\}}	qdYdS0z,t|�D]\}}	||kr�|	Vt|�}q�Wn0t	y�t
t|d|�|�D]\}}	q�Yn0dSr�)�slicer$rWrrr%r�rrZr(r
�	enumerate)
r6rrEr$rWr%rTZnextirr�r
r
rr/�s"$z%TestPurePythonRoughEquivalents.islicec	Cs6|�t|�dd��td��|�t|�ddd��td��|�t|�ddd��td��|�t|�dddd��td��ttd	��}|�t|�|d
��ttd
���|�t|�ttd
d	���ttd	��}|�t|�|d
d
��g�|�t|�ttd
d	���t�}|�t|�|dd
d��dg�|�t|�d
�dS)
Nr�rr�rLr�r�rr�r@rbrr�)rXr	r/r�rrrZ)r%rTr`r
r
r�test_islice_recipe�s  z1TestPurePythonRoughEquivalents.test_islice_recipeN)r*r+r,�staticmethodr/r�r
r
r
rr��s
r�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!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S)0�TestGCcCs|�|�t|�~~dSr)rJrZ)r%�iterator�	containerr
r
r�	makecycle�s
zTestGC.makecyclecCs g}|�tdd|dg�|�dS�Nrrrb)r�rw�r%r^r
r
rr��szTestGC.test_accumulatecCsg}|�t|�|�dSr)r�r�r�r
r
rr��szTestGC.test_chaincCsg}|�t�|g�|�dSr)r�r�r�r�r
r
rr��szTestGC.test_chain_from_iterablecCs"g}|�tdd|dgd�|�dSr�)r�r�r�r
r
rr��szTestGC.test_combinationscCs"g}|�tdd|dgd�|�dSr�)r�r�r�r
r
rr��sz)TestGC.test_combinations_with_replacementcCsg}|�tdgd��|�dS)Nr�)rrrrrr)r�rr�r
r
rr�szTestGC.test_compresscCs6g}tdtft|d��}|�t|d�|d��|�dS)N�Intrrr)rYrxr^r�r)r%r^r�r
r
rr"�szTestGC.test_countcCsg}|�t|gd�|�dSr>)r�r)r�r
r
rr+szTestGC.test_cyclecCs g}|�ttd||g�|�dSr:)r�r�rQr�r
r
rr�szTestGC.test_dropwhilecCs$g}|�t|gddd��|�dS)NrcSs|Srr
rr
r
rrGrHz%TestGC.test_groupby.<locals>.<lambda>)r�r�r�r
r
rrO	szTestGC.test_groupbycCs>d}dd�}tt|�|d�D]\}}|j�dg��|�qdS)Nr@cSs|Srr
rr
r
rrGrHz'TestGC.test_issue2246.<locals>.<lambda>r/r)r�r�__dict__�
setdefaultrJ)r%r!rIrr�r
r
r�test_issue2246
szTestGC.test_issue2246cCs$g}|�tdd�|gd�|�dS)NcSsdS)NTr
rr
r
rrGrHz$TestGC.test_filter.<locals>.<lambda>r)r�r�r�r
r
rrTszTestGC.test_filtercCsg}|�tdd�|�|�dS)NcSsdSr�r
rr
r
rrGrHz)TestGC.test_filterfalse.<locals>.<lambda>)r�rVr�r
r
rrXszTestGC.test_filterfalsecCs&g}|�t|gd|gd�|�dS)Nrrb)r�r
r�r
r
rr]szTestGC.test_zipcCsPg}|�t|gd|gd�|�|dg}|�t|gd|gd|d�|�dS)Nrrbrg)r�ri)r%r^r_r
r
rr� szTestGC.test_zip_longestcCs$g}|�tdd�|gd�|�dS)NcSs|Srr
rr
r
rrG(rHz!TestGC.test_map.<locals>.<lambda>r)r�rzr�r
r
rr�&szTestGC.test_mapcCs g}|�t|gdd�|�dSr>)r�r/r�r
r
rr�*szTestGC.test_islicecCs"g}|�tdd|dgd�|�dSr�)r�r�r�r
r
rr�.szTestGC.test_permutationscCs$g}|�tdd|dgdd�|�dS)Nrrrbr�)r�r�r�r
r
rr�2szTestGC.test_productcCsg}|�t|�|�dSr)r�r�r�r
r
rr�6szTestGC.test_repeatcCs(g}|�tdd�||fgd�|�dS)NcWs|Srr
�r�r
r
rrG<rHz%TestGC.test_starmap.<locals>.<lambda>r)r�r�r�r
r
rr�:szTestGC.test_starmapcCs"g}|�ttdd||g�|�dS)Nrr)r�r�rQr�r
r
rr�>szTestGC.test_takewhileN)r*r+r,r�r�r�r�r�r�rr"r+r�rOrrTrXr]r�r�r�r�r�r�r�r�r
r
r
rr��s.r�ccs|D]
}|VqdS)zRegular generatorNr
��seqnrr
r
r�RBsrc@s eZdZdZdd�Zdd�ZdS)�GzSequence using __getitem__cCs
||_dSr�r�r%rr
r
rrwIsz
G.__init__cCs
|j|Srr)r%rr
r
r�__getitem__Ksz
G.__getitem__N)r*r+r,r-rwr	r
r
r
rrGsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	r�z Sequence using iterator protocolcCs||_d|_dSr:rrr
r
rrwPsz
I.__init__cCs|Srr
r$r
r
rr&Ssz
I.__iter__cCs2|jt|j�krt�|j|j}|jd7_|Sr2�rr�rr(�r%r�r
r
rr)Usz
I.__next__N�r*r+r,r-rwr&r)r
r
r
rr�Nsr�c@s eZdZdZdd�Zdd�ZdS)�Igz9Sequence using iterator protocol defined with a generatorcCs||_d|_dSr:rrr
r
rrw]szIg.__init__ccs|jD]
}|VqdSrrr�r
r
rr&`s
zIg.__iter__N�r*r+r,r-rwr&r
r
r
rr
[sr
c@s eZdZdZdd�Zdd�ZdS)rfz Missing __getitem__ and __iter__cCs||_d|_dSr:rrr
r
rrwfsz
X.__init__cCs2|jt|j�krt�|j|j}|jd7_|Sr2r
rr
r
rr)isz
X.__next__N)r*r+r,r-rwr)r
r
r
rrfdsrfc@s eZdZdZdd�Zdd�ZdS)�NzIterator missing __next__()cCs||_d|_dSr:rrr
r
rrwqsz
N.__init__cCs|Srr
r$r
r
rr&tsz
N.__iter__Nrr
r
r
rrosrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�EzTest propagation of exceptionscCs||_d|_dSr:rrr
r
rrwysz
E.__init__cCs|Srr
r$r
r
rr&|sz
E.__iter__cCsdddS)Nrbrr
r$r
r
rr)~sz
E.__next__Nrr
r
r
rrwsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�SzTest immediate stopcCsdSrr
rr
r
rrw�sz
S.__init__cCs|Srr
r$r
r
rr&�sz
S.__iter__cCst�dSrr'r$r
r
rr)�sz
S.__next__Nrr
r
r
rr�srcCsttdd�ttt|�����S)z Test multiple tiers of iteratorscSs|Srr
rr
r
rrG�rHzL.<locals>.<lambda>)r�rzrr
rrr
r
r�L�src@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�gd�}gd�}t|�}tttttfD]}|�tt||���|�q&|�ttt	|���g�|�
ttt|��|�
ttt
|��|�
tttt|���dSr�)r�rr�r
rrrXr	rwrr{rSrfr�ZeroDivisionErrorr)r%rEr<r!r7r
r
rr��sz'TestVariousIteratorArgs.test_accumulatec	Cs�ddtd�dtddd�fD]�}ttttttfD]V}|�tt	||���t||���|�tt	||�||���t||��t||���q.|�
ttt	t|���|�
ttt	t
|���|�
ttt	t|���qdS�N�123r�r�Zdog333333�?rb�rl)rrr�r
rrrrXr	r�r{rSrfrrr�r%rEr7r
r
rr��s 4z"TestVariousIteratorArgs.test_chainc	Cs�ddtd�dtddd�fD]�}t|�}ttttttfD]*}|�t	t
||�td���t	||���q6|�t
t
t|�td��|�t
t
t|�td��|�tt	t
t|�td���qdS)	Nrr�rrrbrrlr)rr�rr�r
rrrrXr	rr�r{rSrfrrr)r%rEr!r7r
r
rr�s(z%TestVariousIteratorArgs.test_compresscCsZddtd�dtddd�fD]:}|�ttt|��|�ttt|��|�ttt|��qdSr)rr{rSr�rfrrr)r%rEr
r
rr��sz$TestVariousIteratorArgs.test_productcCs�ddtd�dtddd�fD]�}ttttttfD]B}t|�d}t||��d}tt	t
||��|��}|�||�q.|�t
t
t|��|�t
t
t|��|�ttt
t|���qdS)	Nrr�rrrbrrlrb)rrr�r
rrrr�r	r/r)rXr{rSrfrrr)r%rEr7ZtgtlenZexpected�actualr
r
rr+�sz"TestVariousIteratorArgs.test_cyclecCs�td�td�td�dtddd�fD]z}ttttttfD]*}|�dd	�t||��D�t	||���q6|�
ttt|��|�
ttt
|��|�
tt	tt|���q"dS)
Nr@rr�rkr1rbrrlcSsg|]\}}|�qSr
r
)rIr�Zsbr
r
rrJ�rHz8TestVariousIteratorArgs.test_groupby.<locals>.<listcomp>)rrr�r
rrrrXr�r	r{rSrfrrrrr
r
rrO�s&(z$TestVariousIteratorArgs.test_groupbyc	Cs�td�td�td�dtddd�fD]�}ttttttfD],}|�tt	t
||���dd	�||�D��q6|�tt	t
t
|��|�tt	t
t|��|�ttt	t
t|���q"dS)
Nr@rrrrbrrlcSsg|]}t|�r|�qSr
)rr�r
r
rrJ�rHz7TestVariousIteratorArgs.test_filter.<locals>.<listcomp>)rrr�r
rrrrXr	r�rr{rSrfrrrrr
r
rrT�s&�z#TestVariousIteratorArgs.test_filterc	Cs�td�td�td�dtddd�fD]�}ttttttfD],}|�tt	t
||���dd	�||�D��q6|�tt	t
t
|��|�tt	t
t|��|�ttt	t
t|���q"dS)
Nr@rrrrbrrlcSsg|]}t|�r|�qSr
)rr�r
r
rrJ�rHz<TestVariousIteratorArgs.test_filterfalse.<locals>.<listcomp>)rrr�r
rrrrXr	rVrr{rSrfrrrrr
r
rrX�s&�z(TestVariousIteratorArgs.test_filterfalsec	Cs�ddtd�dtddd�fD]�}ttttttfD]P}|�tt	||���t
||���|�tt	||�||���t
||�||���q.|�tt	t
|��|�tt	t|��|�ttt	t|���qdSr)rrr�r
rrrrXr	r
rr{rSrfrrrrr
r
rr]�s .z TestVariousIteratorArgs.test_zipc
Cs�ddtd�dtddd�fD]�}ttttttfD]X}|�tt	||���tt
||����|�tt	||�||���tt
||�||����q.|�tt	t
|��|�tt	t|��|�ttt	t|���qdSr)rrr�r
rrrrXr	rir
r{rSrfrrrrr
r
rrn�s$2z'TestVariousIteratorArgs.test_ziplongestc
Cs�td�td�td�dtddd�fD]�}ttttttfD]\}|�tt	t
||���dd	�||�D��|�tt	tj||�||���d
d	�||�D��q6|�
tt	t
t|��|�
tt	t
t|��|�
ttt	t
t|���q"dS)Nr@rrrrrvr�rlcSsg|]}t|��qSr
)rr�r
r
rrJ�rHz4TestVariousIteratorArgs.test_map.<locals>.<listcomp>cSsg|]}||�qSr
r
r�r
r
rrJ�rH)rrr�r
rrrrXr	rzrr3r�r{rSrfrrrrr
r
rr��s&��z TestVariousIteratorArgs.test_mapc
Cs�ddtd�dtddd�fD]�}ttttttfD]4}|�tt	||�ddd	��t||��ddd	��q.|�
tt	t|�d
�|�
tt	t
|�d
�|�
ttt	t|�d
��qdS)NZ12345r�rrrbrrlrrr@)rrr�r
rrrrXr	r/r{rSrfrrrrr
r
rr��s2z#TestVariousIteratorArgs.test_islicec	Cs�td�td�td�dtddd�fD]�}ttttttfD]8}t||�}|�t	t
tj||���dd	�||�D��q6|�
tt
tjt|��|�
tt
tjt|��|�
tt	t
tjt|���q"dS)
Nr@rrrrrvr�rlcSsg|]}||�qSr
r
r�r
r
rrJrHz8TestVariousIteratorArgs.test_starmap.<locals>.<listcomp>)rrr�r
rrrrrXr	r�r3r�r{rSrfrrr)r%rEr7�ssr
r
rr��s&
�z$TestVariousIteratorArgs.test_starmapc	Cs�td�td�td�dtddd�fD]�}ttttttfD]F}g}||�D]}t|�sVqb|�|�qF|�	t
tt||���|�q6|�t
ttt|��|�t
ttt|��|�tt
ttt|���q"dS�Nr@rrrrbrrl)rrr�r
rrrrrJrXr	r�r{rSrfrrr�r%rEr7ZtgtrMr
r
rr�s&z&TestVariousIteratorArgs.test_takewhilec	Cs�td�td�td�dtddd�fD]�}ttttttfD]H}g}||�D]}|sXt|�rXqF|�|�qF|�	t
tt||���|�q6|�t
ttt|��|�t
ttt|��|�tt
ttt|���q"dSr)rrr�r
rrrrrJrXr	r�r{rSrfrrrrr
r
rr�s&z&TestVariousIteratorArgs.test_dropwhilecCs�ddtd�dtddd�fD]�}ttttttfD]D}t||��\}}|�t	|�t	||���|�t	|�t	||���q.|�
ttt|��|�
ttt
|��|�
tt	tt|��d�qdS)	Nrr�rrrbrrlr)rrr�r
rrrr�rXr	r{rSrfrrr)r%rEr7Zit1Zit2r
r
rr� sz TestVariousIteratorArgs.test_teeN)r*r+r,r�r�rr�r+rOrTrXr]rnr�r�r�r�r�r�r
r
r
rr�s 						
rc@seZdZdd�Zdd�ZdS)�LengthTransparencycCsL|�t�tdd��d�|�t�tdd��d�|�t�td�d�d�dS)Nr�rr��rXr3�length_hintr�r$r
r
rr�,szLengthTransparency.test_repeatcCsh|�t�tdd��d�|�t�tdd��d�|�t�tddd��d�|�t�tddd��d�dS)Nr�rr�r�r r$r
r
rr�1sz2LengthTransparency.test_repeat_with_negative_timesN)r*r+r,r�r�r
r
r
rr*src@s:eZdZdd�Zdd�Zejdd��Zdd�Zd	d
�Z	dS)�RegressionTestscs<dd�}�fdd�}g�|d|d�tt�}|��|�dS)NcsTdgf��fdd�	}t|�}t|�|dd�<t||�}t|gt|���t��dS)Nrcs|r|dd�=�t���|Srr()r!r��r��zr
rr7@s
z@RegressionTests.test_sf_793826.<locals>.mutatingtuple.<locals>.g)r	rzr
r�rZ)Ztuple1r�Ztuple2r7�items�genr
r#r�
mutatingtuple<s
z5RegressionTests.test_sf_793826.<locals>.mutatingtuplecs|att��dd�<dSr)�Tr	r�r�r
rr�Ksz)RegressionTests.test_sf_793826.<locals>.fr�)rLrlrc)r	r(rX)r%r'r��secondr
r)r�test_sf_7938269szRegressionTests.test_sf_793826cs��fdd�}�fdd�}g�|�ttt|�|d���|��ddg�g�|�ttt|�|d���|��ddg�g�|�ttt|���|��ddg�dS)	Nc3s,��d�dV��d�t���d�dS)Nrrr)rJ�AssertionErrorr
�Zhistr
r�gen1Zs


z,RegressionTests.test_sf_950057.<locals>.gen1c3s��d�dV��d�dS)NrbrrL)rJrr-r
r�gen2as
z,RegressionTests.test_sf_950057.<locals>.gen2FrrT)r{r,r	r�rXr))r%r.r/r
r-r�test_sf_950057VszRegressionTests.test_sf_950057cCsNt�dd�td�D��}|�t��t|�Wd�n1s@0YdS)Ncss|]
}dVqdS)r
Nr
)rIZunusedr
r
rr�wrHzERegressionTests.test_long_chain_of_empty_iterables.<locals>.<genexpr>i���)r�r�rr{r(rZr�r
r
r�"test_long_chain_of_empty_iterablesrsz2RegressionTests.test_long_chain_of_empty_iterablescs0�fdd�}ttd�|�D]\}�t��qdS)Ncs|dkrt��|dkS)Nrlrcr�r8r}r
rr�|sz,RegressionTests.test_issue30347_1.<locals>.fr@)r�rr	)r%r�r�r
r}r�test_issue30347_1{sz!RegressionTests.test_issue30347_1csJG��fdd�d�}d�tttd�|��d�td�D]}t�d�q6dS)Ncs"eZdZdd�Z��fdd�ZdS)z,RegressionTests.test_issue30347_2.<locals>.KcSsdSrr
rr
r
rrw�sz5RegressionTests.test_issue30347_2.<locals>.K.__init__cs�d7��dkrt�d�dS)NrTr()r%�other�r7rr
rrD�s
z3RegressionTests.test_issue30347_2.<locals>.K.__eq__N)r*r+r,rwrDr
r4r
r�K�sr5rr@rr)rZr�r)r%r5r�r
r4r�test_issue30347_2�s
	z!RegressionTests.test_issue30347_2N)
r*r+r,r+r0rZskip_if_pgo_taskr1r2r6r
r
r
rr"7s
r"c@seZdZdd�ZdS)�SubclassWithKwargsTestcs�tttttttttt	t
tfD]^�G�fdd�d��}z|dd�Wqtyx}z|�
d|jd�WYd}~qd}~00qdS)NcseZdZd�fdd�	ZdS)zBSubclassWithKwargsTest.test_keywords_in_subclass.<locals>.SubclassNcs�j|g|�R�dSr)rw)r%�newargr��clsr
rrw�szKSubclassWithKwargsTest.test_keywords_in_subclass.<locals>.Subclass.__init__)N)r*r+r,rwr
r9r
r�Subclass�sr;r)r8zkeyword argumentsr)r�r
r�rVr�rzr�r/r�r�r)rrSZassertNotInr)r%r;�errr
r9r�test_keywords_in_subclass�s�z0SubclassWithKwargsTest.test_keywords_in_subclassN)r*r+r,r=r
r
r
rr7�sr7c@s:eZdZdd�ZejZdd�Zdd�Zdd�Zd	d
�Z	dS)�
SizeofTestcCst�d�|_dS)Nr!)�struct�calcsize�ssize_tr$r
r
r�setUp�szSizeofTest.setUpcCsFt�d�}|j}|tdd�|d|j�|td�|d|j�dS)NZ3PirjZ12r)
ririririririririririr@)r�calcobjsize�check_sizeofr�rA�r%�basesize�checkr
r
r�test_product_sizeof�s
zSizeofTest.test_product_sizeofcCsLt�d�}|j}|tdd�|d|j�|ttd�d�|d|j�dS�NZ3Pnir�rbr@rL)rrCrDr�rArrEr
r
r�test_combinations_sizeof�s
z#SizeofTest.test_combinations_sizeofcCsPt}t�d�}|j}||dd�|d|j�||td�d�|d|j�dSrI)r�rrCrDrAr)r%r�rFrGr
r
r�)test_combinations_with_replacement_sizeof�s

z4SizeofTest.test_combinations_with_replacement_sizeofcCs�t�d�}|j}|td�|d|jd|j�|tdd�|d|jd|j�|tdd�|d|jd|j�|ttd�d�|d|jd|j�dS)NZ4Pnir�rLrbr�rlr@)rrCrDr�rArrEr
r
r�test_permutations_sizeof�s
�
�
��z#SizeofTest.test_permutations_sizeofN)
r*r+r,rBrrDrHrJrKrLr
r
r
rr>�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 pad_none(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(pad_none('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
|�|rxttd�rxddl
}dgd}tt|��D]"}t	j
|�|��t��||<qLt|�t	�tjt|�dS)N�gettotalrefcountrrl)rKrr�r"rr7r�r�r>rZrun_unittest�hasattrrr�rr�r�rNrzZrun_doctest�modulesr*)�verboseZtest_classesr��countsrr
r
r�	test_main
s �


rS�__main__T)rQ)N)@Zunittest�testr�	itertoolsr��decimalrZ	fractionsrr3r�r�rB�	functoolsrrr?r�r�ZMAX_Py_ssize_trZminsizerrrrrrrr"r#r1r7r9r=r?rArrr�ZTestCaserKr�r�r�rrr�r
rfrrrrrrr"r7r�r>rMZ__test__rSr*r
r
r
r�<module>s�
�~n*e
	
	
\&;



Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists