403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.130
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-2.pyc
3

�
�^��@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�3/opt/alt/python36/lib64/python3.6/test_itertools.py�lzipsr
cCsd|S)N�r)�xrrr�oneargsrcGst�dS)N)�
ValueError)r
rrr�errfuncsrccsxdD]
}|VqWdS)Nrrr)rrrr)�irrr�gen3s
rcCs|ddkS)Nrrr)rrrr�isEven!srcCs|ddkS)Nrrr)rrrr�isOdd%srcGs|S)Nr)r
rrr�tupleize)srccsxt|�D]
}|Vq
WdS)N)�range)�nrrrr�irange,src@seZdZdd�Zdd�ZdS)�StopNowcCs|S)Nr)�selfrrr�__iter__2szStopNow.__iter__cCst�dS)N)�
StopIteration)rrrr�__next__4szStopNow.__next__N)�__name__�
__module__�__qualname__rrrrrrr0srcCstt||��S)N)r�islice)r�seqrrr�take7sr%cCsttj|d�S)Nr)r�operator�mul)�iterablerrr�prod;sr)cCsttd|d��S)Nr)r)r)rrrr�fact>sr*cCs|dS)Nrr)�rrrr�testRCsr,cCs|dS)Nrr)r+rrr�testR2Fsr-cCs|dkS)N�
r)rrrr�undertenIsr/cCsg|]}|fdd��qS)cSstjtj||��S)N)�pickle�loads�dumps)�s�protorrr�<lambda>Lsz<listcomp>.<lambda>r)�.0r4rrr�
<listcomp>Lsr7c@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)NrcsZ�dkrtd��t|t�r|Sytt|���}Wntk
rD|SX��fdd�|D�S)Nr.zinfinite recursion encounteredcsg|]}�|�d��qS)rr)r6�e)�expandrrrr7]sz;TestBasicOps.pickletest.<locals>.expand.<locals>.<listcomp>)�RuntimeError�
isinstance�strrr#�	TypeError)�itr�l)r;�stop)rrr;Ss
z'TestBasicOps.pickletest.<locals>.expandr)r)r0r2r1�assertEqual�typer�nextr)rZprotocolr@rBr%�compare�dumpZi2�a�b�cZi3ZtookrZi4r)r;rBr�
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(�abcrH�ab��)rr��	r9��i�i�)rCr�
accumulater�int�complexrr�map�assertRaisesr?�min�maxr&r'�chrr0�HIGHEST_PROTOCOLrK)r�typr3r4rrr�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)Nr)�	iterablesr@�elementrrr�chain2�s

z'TestBasicOps.test_chain.<locals>.chain2rS�def�abcdef�r9�abcdrrL)�chainrCrr%r_r?)rrhrJrrr�
test_chain�szTestBasicOps.test_chaincCs�|jttjddg��td��|jttjdg��td��|jttjdg��g�|jtdtjddg��td��|jtttjddg��dS)	NrSrirjrkr9rlrrL)rCrrm�
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)
NrSrirjrHZbcdefrkr9rlrrLr)rF)�copy�deepcopy�
picklecopiersrmrCrrEr%r_r?rr0rcrK)rZoperr@r4rrr�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)NrrSrirHrIrJ�dr:�fZghi)r_r?rm�__setstate__�iterrCr)rr@rrr�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).NrSrrcSs|S)Nr)rHrrrr5�sz0TestBasicOps.test_combinations.<locals>.<lambda>� �ABCD�A�B�C�Dr9rLrc3s�t|��t��}||krdStt|��}t�fdd�|D��Vx�x.tt|��D]}|||||krPPqPWdS||d7<x*t|d|�D]}||dd||<q�Wt�fdd�|D��VqBWdS)Nc3s|]}�|VqdS)Nr)r6r)�poolrr�	<genexpr>�szHTestBasicOps.test_combinations.<locals>.combinations1.<locals>.<genexpr>rc3s|]}�|VqdS)Nr)r6r)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)Nc3s|]}�|VqdS)Nr)r6r)r�rrr��szHTestBasicOps.test_combinations.<locals>.combinations2.<locals>.<genexpr>)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)Nc3s|]}�|VqdS)Nr)r6r)r�rrr�szHTestBasicOps.test_combinations.<locals>.combinations3.<locals>.<genexpr>)r�r��combinations_with_replacementr�set)r(r+rr�r)r�r�
combinations3�s
z5TestBasicOps.test_combinations.<locals>.combinations3rUcSsg|]}d|d�qS)rV�r)r6rrrrr7sz2TestBasicOps.test_combinations.<locals>.<listcomp>c3s|]}|�kVqdS)Nr)r6r:)�valuesrrr�
sz1TestBasicOps.test_combinations.<locals>.<genexpr>csg|]}|�kr|�qSrr)r6r:)rJrrr7s���)r|r})r|r~)r|r)r}r~)r}r)r~r)r|r~)r|r)r}r~)r}r)r~r)rrr)rrrL)rrrL)rrrL)rrrL)rrrL)rrrL)r_r?�combinationsrrsrCrrErr�r*r�r��
assertTrue�allr0rcrK)
r�op�testIntermediater�r�r�rr+�resultr4r)rJr�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�abcderLr)rCr�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)$NrSrrcSs|S)Nr)rHrrrr5)szATestBasicOps.test_combinations_with_replacement.<locals>.<lambda>�ABCr|r}r~c3s�t|��t��}|r|rdSdg|}t�fdd�|D��Vxfx*tt|��D]}|||dkrPPqPWdS||dg||||d�<t�fdd�|D��VqBWdS)Nrc3s|]}�|VqdS)Nr)r6r)r�rrr�:szPTestBasicOps.test_combinations_with_replacement.<locals>.cwr1.<locals>.<genexpr>rc3s|]}�|VqdS)Nr)r6r)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)N)�repeatc3s|]}�|VqdS)Nr)r6r)r�rrr�JszPTestBasicOps.test_combinations_with_replacement.<locals>.cwr2.<locals>.<genexpr>)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>.numcombsrUcSsg|]}d|d�qS)rVr�r)r6rrrrr7RszCTestBasicOps.test_combinations_with_replacement.<locals>.<listcomp>rcSsg|]\}}|�qSrr)r6�k�vrrrr7bsc3s|]}|�kVqdS)Nr)r6r:)r�rrr�eszBTestBasicOps.test_combinations_with_replacement.<locals>.<genexpr>csg|]}|�kr|�qSrr)r6r:)rJrrr7gsr�)r|r|)r|r})r|r~)r}r})r}r~)r~r~)r|r})r|r~)r}r})r}r~)r~r~)r�r_r?rrsrCrrErr�r�r�r�r��groupbyr�r0rcrK)
r�cwrr�r�r�r�r�rr+r�Z
regular_combsZnorunsr4r)rJr�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�rLr)r�rCr�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)NrSrrrzr3rLrc3s@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)Nrc3s|]}�|VqdS)Nr)r6r)r�rrr��szHTestBasicOps.test_permutations.<locals>.permutations1.<locals>.<genexpr>rc3s|]}�|VqdS)Nr)r6r)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)N)r�c3s|]}�|VqdS)Nr)r6r)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>.permutations2rUcSsg|]}d|d�qS)rVr�r)r6rrrrr7�sz2TestBasicOps.test_permutations.<locals>.<listcomp>c3s|]}|�kVqdS)Nr)r6r:)r�rrr��sz1TestBasicOps.test_permutations.<locals>.<genexpr>r�)rr)rr)rr)rr)rr)rr)N)N)r_r?r�rrCrrr�r*r�r�r�r�r0rcrK)rr�r�rr+r��pr4r)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�rLr)rCr�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)NrM�ABCDEFGrW)r�rrcSs g|]}t|�t|�kr|�qSr)r�r)r6�trrrr7�sz3TestBasicOps.test_combinatorics.<locals>.<listcomp>cs g|]}tt|���kr|�qSr)r�r�)r6r�)r+rrr7�scSs g|]}t|�t|�kr|�qSr)r�r)r6r�rrrr7�scs g|]}tt|���kr|�qSr)r�r�)r6r�)r+rrr7�s)
rrr�r�r�r�rCr�r*r�r��filter�__contains__)rrr3r)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�ACEFrkZACr�ZBCi'rMrLrVcSs
tj|�S)N)rq)rHrrrr5�sz,TestBasicOps.test_compress.<locals>.<lambda>cSs
tj|�S)N)rqrr)rHrrrr5�sZCEFZBCDEFr~)rr)rCr�compressrmror�rr_r?rsrE)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)8NrSrHrrIrrJrrLr9rVr.g
@g@g@y@z1.1z2.1z3.1rWi�zcount(3)zcount(4)rXz	count(-9)g�$@zcount(10.25)g$@zcount(10.0)z	count(%r))rHr)rIr)rJr)rHrL)rIr9)rJrV)rHrL)rIr9r�r�)rHr�)rIr���r�)rHr�r�)rIr�y
@�y
@�y@�y@�i����i����i����r�r�)rCr
�countr%r	r_r?�maxsizerrrr�reprrErD�float�sys�__mod__rqrrr0rcrK�exc_info)r�BIGINTrJr�r1�r2�valuer4rrr�
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)QNrSrrLrHrIrVrJrW)�start�stepr)r�rr9�rN�dr.g�?g
@g@y@g@g!@y @z1.1z.1z1.2z1.3rU�rOi�g@g)@g.@zcount(3, 5)zcount(8, 5)rXz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))rHr)rIrV)rJrW)rHr)rIrV)rJrWr�)rHrr�)rIr�r�)rJr�)rHr)rIr)rJr)rHr)rIrL)rJr9)rHr)rIrV)rJrWy
@�y@�y!@ �i����i����r�i����r�i����r�)rCr
r�r_r?r%r�rrrrr�rErDr\r�r�r0rcrK)rr�rJrr�r�r�r4rrr�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.rSZ
abcabcabcarkrVrrrrHZ
bcabcabcabZ
cabcabcabcr�csg|]}t���qSr)rE)r6r)rJrrr7�sz+TestBasicOps.test_cycle.<locals>.<listcomp>r�Zcdeabcdeabcdeabcdeabcsg|]}t���qSr)rE)r6r)rJrrr7�srU)rCr%�cyclerr_r?r#rrErqrrrr0rcr1r2rKrx)rr4r@�_r�rur)rJr�
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�defgrSrr�Zdefgabcdefgabcdefgab�abcdefgrrrk)r�rwrrCr%r_r?r�)rrJrrr�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)�keyrScSs|S)Nr)rrrrr5�sz+TestBasicOps.test_groupby.<locals>.<lambda>r.rr��rOr�r�
��rrNrLrY�r�cSs|dS)Nrr)r+rrrr5�scSsg|]\}}|�qSrr)r6r��grrrr7�sz-TestBasicOps.test_groupby.<locals>.<listcomp>cSsg|]}|d�qS)rr)r6r+rrrr7�sZabracadabracSsg|]\}}|�qSrr)r6r�r�rrrr7�srHrIrJrur+cSs$g|]\}}tt|dd��r|�qS)rr)rr#)r6r�r�rrrr7�scSs g|]\}}tt|��|f�qSr)r�r)r6r�r�rrrr7�srVcSs g|]\}}tt|��|f�qSr)r�r)r6r�r�rrrr7�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)r6r�r�)�funcrrr7	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�rO)rr�rO)rr�rO)rr�r�)rrNr�)rLrYr�)rLr�r�)rVrH)rrI)rrJ)rru)rr+)rVrH)rr+)rrI)r)rCrr�r�r_r?�appendrr0rcr1r2r,r-r�r�r��	Exceptionr�)rr3�dupr�r��elemr4ZikZig�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)NrMrrr9rcSs|S)Nr)rrrrr5/sz*TestBasicOps.test_filter.<locals>.<lambda>cSs|S)Nr)rrrrr50srUrL)rCrr�rr�boolr%r�r_r?rErqrrr0rcr1r2rK)r�ansrJr4rrr�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)NrMrrLrVrrr9rUcSs|S)Nr)rrrrr5Jsz/TestBasicOps.test_filterfalse.<locals>.<lambda>cSs|S)Nr)rrrrr5Ks)rCr�filterfalserrr�r%r�r_r?rEr0rcrK)rr4rrr�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)r6r�yrrrr7Ssz)TestBasicOps.test_zip.<locals>.<listcomp>rSrHrrIrrJrrMrjrLcSsg|]}tt|���qSr)r�r)r6�pairrrrr7\sricSsg|]}|�qSrr)r6r�rrrr7^s)rHr)rIr)rJr)	r	r�rCrrr
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)NrSricSsg|]\}}||f�qSrr)r6rr�rrrr7isz5TestBasicOps.test_zip_tuple_reuse.<locals>.<listcomp>rHrrIrrJrcSsg|]\}}||f�qSrr)r6rr�rrrr7lscSsg|]\}}||f�qSrr)r6rr�rrrr7pscSsg|]\}}||f�qSrr)r6rr�rrrr7vs)rHr)rIr)rJr)rHr)rIr)rJr)rHr)rIr)rJr)rIr)rJr)rr^r�r	rCr`rar��dict�fromkeysrqr�rrrr0rcr1r2rErK)r�idsr�r4r�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)NrSrMi�i�i4i�i�ri�i�cs"g|]�t�fdd��D���qS)cs$g|]}�t|�kr|�nd�qS)N)r�)r6�arg)rrrr7�sz;TestBasicOps.test_ziplongest.<locals>.<listcomp>.<listcomp>)r�)r6)r
)rrr7�sz0TestBasicOps.test_ziplongest.<locals>.<listcomp>cSsg|]}tdd�|D���qS)css|]}|dkrdp|VqdS)N�Xr)r6r:rrrr��sz:TestBasicOps.test_ziplongest.<locals>.<listcomp>.<genexpr>)r�)r6r�rrrr7�sr�)�	fillvaluerLrjr��zip_longest('abc', fv=1)�3zip_longest('abc', fillvalue=1, bogus_keyword=None)zDid not raise Type in:  cSsg|]}tt|���qSr)r�r)r6r�rrrr7�sricSsg|]}|�qSrr)r6r�rrrr7�s)rSr�)rr)rrar^r�rCr�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)NrSri)
rr^r�rrCr`rar�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)NrrSriZdefgh)rrk)rr0rcrKr)rr4rrr�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:)rrr�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�rr:)rrrrr�s
z5TestBasicOps.test_bug_7244.<locals>.Repeater.__next__N)r r!r"rrrrrrr�Repeater�sr
rrLrr9cSsTg}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)rrCr<rrEr_)rr
r�r�rr@rrr�
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)#NrTrHrIrrLrrr9)r�rUrMcs�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�)r6r�rrrr��sz>TestBasicOps.test_product.<locals>.product1.<locals>.<genexpr>css|]\}}||VqdS)Nr)r6r�rrrrr��scss|]\}}||VqdS)Nr)r6r�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)Nr�rcs g|]}�D]}||g�qqSrr)r6rr�)r�rrr7sz?TestBasicOps.test_product.<locals>.product2.<locals>.<listcomp>)rr^r�r)r
rrr�r)r)r�r�product2s

z+TestBasicOps.test_product.<locals>.product2rkrS)rHrIrJr�r�r�r�csg|]}tj���qSr)�random�choice)r6r�)�argtypesrrr7sz-TestBasicOps.test_product.<locals>.<listcomp>rV)rH)rI)rr)rr)rr)rr)rr)rri��)rrCrr�r�r�r_r?r�r�rZ	randranger)r^rx)rr
r�r+rrrZexpected_lenr)rr�test_product�s2$"	
zTestBasicOps.test_productcCs2|jttf��tdgdddi�WdQRXdS)NrTrrVr��rzi)r_r�r�r�)rrrr�test_product_overflowsz"TestBasicOps.test_product_overflowc	CsH|jtttttdd����d�|jttttttdd�����d�dS)NrSrir)rCr�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)NrTrHrIrrLrr)rH)rI)rr)rr)rr)rr)rr)rr)	rrCrrqr�rrr0rcrK)rr
r�r4rrr�test_product_pickling s$z"TestBasicOps.test_product_picklingcCsLtdd�}|jd�|jt|�d	�td
fd�}|jd�|jtt|�dS)
NrrrLr�)rr)rL)rr )rrL)rr)rL)rrr )r�rwrCrEr_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)NrHrL)�object�timesrrrr9yzrepeat((1+0j))rVzrepeat((1+0j), 5)zrepeat((1+0j), 0)r.)rrH)rrH)rrHr�y�?y�?�aar$)rCrr�r
rr%r_r?r�rErqrrr0rcrK)rr+rJr4rrr�test_repeat9s,
zTestBasicOps.test_repeatcCs`|jttdd��d�|jttdd��d�|jttddd��d�|jttdd	d��d�dS)
NrHrzrepeat('a', 0)r)r#r�r�r�r�)rCr�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)NrLrrUrrrSrVrHrIrJr.r9rrrW)rHr)rIr)rJr)rHr)rIr)rJr)rHr)rIr)rHr)rIr)rJr)rCrr^r&�powrrr�r%r_r?�negrErrrrqrrr0rcrK)rr�rJr4rrr�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)NrLrrUrrr9rV�extrar.rrrWrrrWi)r9rV)r9rV)r9rV)r9rVrrrW)rCr�starmapr&r'r	rr%r�rxr_r?rErrrrqrrr0rcrK)rr�rJr4rrr�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�rLr��nrrr9rVrrH�2css|]
}|VqdS)Nr)r6rrrrr��sz+TestBasicOps.test_islice.<locals>.<genexpr>�r.r�rL�r.rLr��r.r��r.r.�r.rL�r�)r/r0r1r2r3r4�r.r-rL�r.r�rL�r5r6�r.r-�r.r��r8r9�r-�r��r;r<)r7r:r=���r>r�r��r.r�rL�r.rLr��r.r��r.rL�r�)r?r@rArBrC)rr)rCrr#rrxr_r?rr�r�r�rErqrrr0rcrK�weakref�refZassertIsNotNonerZ
gc_collectZassertIsNone)rr
Ztgtargsr@ZrarJr4�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)NrrLrVr�rr9rMrWr*r.r)r9rV)r9rV)r9rV)rCr�	takewhiler/r_r?r&r'rErrr�rrqrrrr0rcrK)rr�r�r4rrr�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)NrrLrVr�rr9rMrWr*r.)r9rV)r9rV)r9rV)rCr�	dropwhiler/r_r?r&r'rErrrqrrrr0rcrK)rr�r4rrr�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�rVrrrLrrrSrii�ZinvalidcSsg|]}t|��qSr)r)r6rrrrr7Hsz)TestBasicOps.test_tee.<locals>.<listcomp>r.�	__class__i'�<)rFr�)�teerCrrr
rrErZshuffler�r_r?rDrr�r�r�rD�proxy�getattr�ReferenceErrorrqr%rrr0rcrKrx)rrrHrIrr��orderZlistsZitsr�rJr�ruZt1Zt2ZtnewZt3r�r�Zlong_ansr4rrr�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r5�sz1TestBasicOps.test_StopIteration.<locals>.<lambda>cSs|S)Nr)rrrrr5�s)r_rrEr	rmr�r�rr#rOr�r�r�r^rHrJr+)rrvr��qrrr�test_StopIteration�s zTestBasicOps.test_StopIteration)r9rN)3r r!r"rKrernrprtryr�rZbigaddrspacetestr�Zimpl_detailr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr	r
rrrrrr!r%r&r)r,rGrIrKrTrUrWrrrrr8Os\
)

PL?!"07*$n
*(:
Q	r8c@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)	NrrrLr9rVrMr.rN)rCrr[)rrrrre�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)	NrrrLr9rVrMr.rN)rr0rcr[rCrr1r2rErqrr)rr�Zaccumulatedr4r@rrr�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_rCrErr0rcr1r2rrqrr)rr@r4Zit_copyrrr�test_accumulate_reducible_none�sz+TestExamples.test_accumulate_reducible_nonecCs|jdjtdd��d�dS)Nrkr��DEFr�)rC�joinrm)rrrrrn�szTestExamples.test_chaincCs |jdjtjddg��d�dS)Nrkr�r\r�)rCr]rmro)rrrrrp�sz%TestExamples.test_chain_from_iterablec	CsH|jttdd��ddd
dddg�|jtttd�d��ddddg�dS)Nr{rr|r}r~rr9rLrr)r|r})r|r~)r|r)r}r~)r}r)r~r)rrr)rrrL)rrrL)rrrL)rCrr�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~)r~r~)rCrr�)rrrrr��sz/TestExamples.test_combinations_with_replacementc
Cs*|jttdddddddg��td��dS)Nr�rrr�)rCrr�)rrrrr��szTestExamples.test_compresscCs(|jtttd�d��dddddg�dS)Nr.rVr�r�r�r�)rCrr#r�)rrrrr��szTestExamples.test_countcCs"|jtttd�d��td��dS)Nr{r�ZABCDABCDABCD)rCrr#r�)rrrrr��szTestExamples.test_cyclec	Cs.|jttdd�dddddg��dddg�dS)NcSs|dkS)NrVr)rrrrr5�sz-TestExamples.test_dropwhile.<locals>.<lambda>rr9rM)rCrrJ)rrrrrK�szTestExamples.test_dropwhilecCsT|jdd�td�D�td��|jdd�td�D�td�td�td	�td
�g�dS)NcSsg|]\}}|�qSrr)r6r�r�rrrr7�sz-TestExamples.test_groupby.<locals>.<listcomp>ZAAAABBBCCDAABBBZABCDABcSsg|]\}}t|��qSr)r)r6r�r�rrrr7�sZ
AAAABBBCCDZAAAAZBBB�CCr)rCr�r)rrrrr��s
zTestExamples.test_groupbycCs,|jttdd�td���dddddg�dS)	NcSs|dS)Nrr)rrrrr5�sz*TestExamples.test_filter.<locals>.<lambda>r.rrLrVrUrX)rCrr�r)rrrrr��szTestExamples.test_filtercCs,|jttdd�td���dddddg�dS)	NcSs|dS)Nrr)rrrrr5sz/TestExamples.test_filterfalse.<locals>.<lambda>r.rrr9rMrW)rCrr�r)rrrrr�szTestExamples.test_filterfalsecCs"|jtttdd	��dddg�dS)
NrrLr.rVrzrXi�)rrLr.)rVrrL)rCrr^r')rrrrr)szTestExamples.test_mapcCst|jttdd��td��|jttddd��td��|jttddd��td��|jttdddd��td��dS)	Nr�r�ABr9�CD�CDEFGr�ACEG)rCrr#)rrrrrGszTestExamples.test_islicecCs|jttdd��ddg�dS)	Nr{�xyr|rr}r�)r|r)r}r�)rCrr	)rrrrr�szTestExamples.test_zipcCs&|jttdddd��ddd
dg�dS)Nr{rc�-)rr|rr}r�r~r)r|r)r}r�)r~rd)rrd)rCrr)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 DCrLrr)rrr)rrr)rrr)rrr)rrr)rrr)rCrr�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 DyrrL)r�rr)rrr)rrr)rrr)rrr)rrr)rrr)rrr)rrr)rCrr�r^r�rfr)rrrrrs
zTestExamples.test_productcCs |jttdd��dddg�dS)Nr.rL)rCrr�)rrrrr% szTestExamples.test_repeatcCs&|jtttdd	d
g��dddg�dS)NrrVrLr.rzrXi�)rrV)rLr)r.rL)rCrr+r')rrrr�test_stapmap#szTestExamples.test_stapmapc	Cs,|jttdd�dddddg��ddg�dS)NcSs|dkS)NrVr)rrrrr5(sz-TestExamples.test_takewhile.<locals>.<lambda>rr9rM)rCrrH)rrrrrI'szTestExamples.test_takewhileN)r r!r"rerYr[rnrpr�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�rBr�r�r�rxrrErr	�	enumerate)
r(r
r3r�rBr�r@Znextirrgrrr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_r9r`rarrbr.rLrr.)rCrr#rxrr�rE)rr@rJrrr�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�rE)r�iterator�	containerrrr�	makecycleWs
zTestGC.makecyclecCs g}|jtdd|dg�|�dS)NrrrL)rpr[)rrHrrrre\szTestGC.test_accumulatecCsg}|jt|�|�dS)N)rprm)rrHrrrrn`szTestGC.test_chaincCsg}|jtj|g�|�dS)N)rprmro)rrHrrrrpdszTestGC.test_chain_from_iterablecCs"g}|jtdd|dgd�|�dS)NrrrL)rpr�)rrHrrrr�hszTestGC.test_combinationscCs"g}|jtdd|dgd�|�dS)NrrrL)rpr�)rrHrrrr�lsz)TestGC.test_combinations_with_replacementc	Cs&g}|jtdddddddg�|�dS)Nr�rr)rpr�)rrHrrrr�pszTestGC.test_compresscCs6g}tdtft|d��}|jt|d�|d��|�dS)N�Int)rrr)rDr\r�rpr�)rrHrqrrrr�tszTestGC.test_countcCsg}|jt|gd�|�dS)Nr)rpr�)rrHrrrr�yszTestGC.test_cyclecCs g}|jttd||g�|�dS)Nr)rprJr�)rrHrrrrK}szTestGC.test_dropwhilecCs$g}|jt|gddd��|�dS)NrcSs|S)Nr)rrrrr5�sz%TestGC.test_groupby.<locals>.<lambda>)rpr�)rrHrrrr��szTestGC.test_groupbycCsBd}dd�}x0tt|�|d�D]\}}|jjdg�j|�qWdS)Nr.cSs|S)Nr)rrrrr5�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r5�sz$TestGC.test_filter.<locals>.<lambda>r)rpr�)rrHrrrr��szTestGC.test_filtercCsg}|jtdd�|�|�dS)NcSsdS)NFr)rrrrr5�sz)TestGC.test_filterfalse.<locals>.<lambda>)rpr�)rrHrrrr��szTestGC.test_filterfalsecCs&g}|jt|gd|gd�|�dS)NrrL)rpr	)rrHrrrr��szTestGC.test_zipcCsPg}|jt|gd|gd�|�|dg}|jt|gd|gd|d�|�dS)NrrL)r)rpr)rrHrIrrrre�szTestGC.test_zip_longestcCs$g}|jtdd�|gd�|�dS)NcSs|S)Nr)rrrrr5�sz!TestGC.test_map.<locals>.<lambda>r)rpr^)rrHrrrr)�szTestGC.test_mapcCs g}|jt|gdd�|�dS)Nr)rpr#)rrHrrrrG�szTestGC.test_islicecCs"g}|jtdd|dgd�|�dS)NrrrL)rpr�)rrHrrrr��szTestGC.test_permutationscCs$g}|jtdd|dgdd�|�dS)NrrrL)r�)rpr�)rrHrrrr�szTestGC.test_productcCsg}|jt|�|�dS)N)rpr�)rrHrrrr%�szTestGC.test_repeatcCs(g}|jtdd�||fgd�|�dS)NcWs|S)Nr)r�rrrr5�sz%TestGC.test_starmap.<locals>.<lambda>r)rpr+)rrHrrrr,�szTestGC.test_starmapcCs"g}|jttdd||g�|�dS)Nrr)rprHr�)rrHrrrrI�szTestGC.test_takewhileN)r r!r"rprernrpr�r�r�r�r�rKr�rtr�r�r�rer)rGr�rr%r,rIrrrrrmUs.rmccsx|D]
}|VqWdS)Nr)�seqnrrrr�R�s
rvc@seZdZdd�Zdd�ZdS)�GcCs
||_dS)N)ru)rrurrrr�sz
G.__init__cCs
|j|S)N)ru)rrrrr�__getitem__�sz
G.__getitem__N)r r!r"rrxrrrrrw�srwc@s$eZdZdd�Zdd�Zdd�ZdS)�IcCs||_d|_dS)Nr)rur)rrurrrr�sz
I.__init__cCs|S)Nr)rrrrr�sz
I.__iter__cCs2|jt|j�krt�|j|j}|jd7_|S)Nr)rr�rur)rr�rrrr�s
z
I.__next__N)r r!r"rrrrrrrry�sryc@seZdZdd�Zdd�ZdS)�IgcCs||_d|_dS)Nr)rur)rrurrrr�szIg.__init__ccsx|jD]
}|VqWdS)N)ru)r�valrrrr�szIg.__iter__N)r r!r"rrrrrrrz�srzc@seZdZdd�Zdd�ZdS)r�cCs||_d|_dS)Nr)rur)rrurrrr�sz
X.__init__cCs2|jt|j�krt�|j|j}|jd7_|S)Nr)rr�rur)rr�rrrr�s
z
X.__next__N)r r!r"rrrrrrr��sr�c@seZdZdd�Zdd�ZdS)�NcCs||_d|_dS)Nr)rur)rrurrrr�sz
N.__init__cCs|S)Nr)rrrrr�sz
N.__iter__N)r r!r"rrrrrrr|�sr|c@s$eZdZdd�Zdd�Zdd�ZdS)�EcCs||_d|_dS)Nr)rur)rrurrrr�sz
E.__init__cCs|S)Nr)rrrrr�sz
E.__iter__cCsdddS)NrLrr)rrrrr�sz
E.__next__N)r r!r"rrrrrrrr}�sr}c@s$eZdZdd�Zdd�Zdd�ZdS)�ScCsdS)Nr)rrurrr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rrrrrrr~�sr~cCsttdd�ttt|�����S)NcSs|S)Nr)rrrrr5szL.<locals>.<lambda>)rmr^rvrzrw)rurrr�Lsrc@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)	NrrrLr9rVrMr.rN)r�rwryrzrrvrCrr[r~r_r?r�r|�ZeroDivisionErrorr})rr3r+rr�rrrre	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�123rki��do�333333�?i�i�rV)r�r�)rrwryrzr~rrvrCrrmr_r?r�r|r�r})rr3r�rrrrns  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�rki�r��333333�?i�i�rVr)r�r�)rr�rwryrzr~rrvrCrr�r�r_r?r�r|r�r})rr3rr�rrrr�s *z%TestVariousIteratorArgs.test_compresscCs^xXddtd�d	tddd�fD]:}|jttt|��|jttt|��|jttt|��qWdS)
Nr�rki�r��333333�?i�i�rV)r�r�)rr_r?r�r�r|r�r})rr3rrr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�rki�r��333333�?i�i�rVrL)r�r�)rrwryrzr~rrvr�rr#r�rCr_r?r�r|r�r})rr3r�ZtgtlenZexpected�actualrrr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�rUr�i�i�rVcSsg|]\}}|�qSrr)r6r�Zsbrrrr7:sz8TestVariousIteratorArgs.test_groupby.<locals>.<listcomp>)rUr�)rrwryrzr~rrvrCr�rr_r?r�r|r�r})rr3r�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�rUr�i�i�rVcSsg|]}t|�r|�qSr)r)r6rrrrr7Csz7TestVariousIteratorArgs.test_filter.<locals>.<listcomp>)rUr�)rrwryrzr~rrvrCrr�rr_r?r�r|r�r})rr3r�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�rUr�i�i�rVcSsg|]}t|�r|�qSr)r)r6rrrrr7Lsz<TestVariousIteratorArgs.test_filterfalse.<locals>.<listcomp>)rUr�)rrwryrzr~rrvrCrr�rr_r?r�r|r�r})rr3r�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�rki�r��333333�?i�i�rV)r�r�)rrwryrzr~rrvrCrr	r
r_r?r�r|r�r})rr3r�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�rki�r��333333�?i�i�rV)r�r�)rrwryrzr~rrvrCrrr	r_r?r�r|r�r})rr3r�rrrrZs $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�rUr�r�r.rVcSsg|]}t|��qSr)r)r6rrrrr7gsz4TestVariousIteratorArgs.test_map.<locals>.<listcomp>cSsg|]}||�qSrr)r6rrrrr7is)rUr�)rrwryrzr~rrvrCrr^rr&r'r_r?r�r|r�r})rr3r�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)
NZ12345rki�r��333333�?i�i�rVrrr.)r�r�)rrwryrzr~rrvrCrr#r_r?r�r|r�r})rr3r�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�rUr�r�r.rVcSsg|]}||�qSrr)r6rrrrr7{sz8TestVariousIteratorArgs.test_starmap.<locals>.<listcomp>)rUr�)rrwryrzr~rrvr
rCrr+r&r'r_r?r�r|r�r})rr3r��ssrrr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�rUr�i�i�rV)rUr�)rrwryrzr~rrvrr�rCrrHr_r?r�r|r�r})rr3r��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�rUr�i�i�rV)rUr�)rrwryrzr~rrvrr�rCrrJr_r?r�r|r�r})rr3r�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�rki�r��333333�?i�i�rVr)r�r�)rrwryrzr~rrvrOrCrr_r?r�r|r�r})rr3r�Zit1Zit2rrrrT�s z TestVariousIteratorArgs.test_teeN)r r!r"rernr�rr�r�r�r�r�rr)rGr,rIrKrTrrrrr�s 						
r�c@seZdZdd�Zdd�ZdS)�LengthTransparencycCsL|jtjtdd��d�|jtjtdd��d�|jtjtd�d�d�dS)Nr.rr�)rCr&�length_hintr�)rrrrr%�szLengthTransparency.test_repeatcCsh|jtjtdd��d�|jtjtdd��d�|jtjtddd��d�|jtjtddd��d�dS)	Nrrr)r#r�r�r�r�)rCr&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)rE)r��first)rv�zrrr��s
z@RegressionTests.test_sf_793826.<locals>.mutatingtuple.<locals>.g)rr^r	r�rE)Ztuple1rvZtuple2r��items�genr)rvr�r�
mutatingtuple�s
z5RegressionTests.test_sf_793826.<locals>.mutatingtuplecs|att��dd�<dS)N)�Tr)r�)r�rrrv�sz)RegressionTests.test_sf_793826.<locals>.frrrLr9rVrM)rrrL)r9rVrM)rr�rC)rr�rv�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)NrLrr9)r�)r)r�rr�gen2�s
z,RegressionTests.test_sf_950057.<locals>.gen2FrrT)r_r�rrmrCr�)rr�r�r)r�r�test_sf_950057�szRegressionTests.test_sf_950057c	Cs:tjdd�td�D��}|jt��t|�WdQRXdS)Ncss|]
}fVqdS)Nr)r6Zunusedrrrr��szERegressionTests.test_long_chain_of_empty_iterables.<locals>.<genexpr>i���)rmrorr_rrE)rr@rrr�"test_long_chain_of_empty_iterables�sz2RegressionTests.test_long_chain_of_empty_iterablescs4�fdd�}x"ttd�|�D]\}�t��qWdS)Ncs|dkrt��|dkS)NrVrM)r)r)rIrrrv�sz,RegressionTests.test_issue30347_1.<locals>.fr.)r�rr)rrvr�r)rIr�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)rE)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)rEr�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�rmr^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)�struct�calcsize�ssize_t)rrrr�setUpszSizeofTest.setUpcCsFtjd�}|j}|tdd�|d|j�|td�|d|j�dS)	NZ3PirTZ12rrSr.)rS)
rSrSrSrSrSrSrSrSrSrS)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�3PnirlrLr.r9)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�rlrLr.r9)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)NZ4Pnirlr9rLr�rVr.)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�gettotalrefcountrrV)r8r�rmr�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&rrqr0�	functoolsrr�r�ZMAX_Py_ssize_tr�Zminsizer
rrrrrrrrr%r)r*r,r-r/rrcrsZTestCaser8rXrhrmrvrwryrzr�r|r}r~rr�r�r�r�Zcpython_onlyr�r�Z__test__r�r rrrr�<module>s�
xn*e
	
	
[
_



Youez - 2016 - github.com/yon3zu
LinuXploit