U
    lª/e®V  ã                   @   sX   d dl Z d dlZd dlmZ d dlZddlmZ dddgZe	ddƒZ
G d	d
„ d
eƒZdS )é    N)ÚTestCaseé   )Ú
async_testÚAÚBÚCé   c                   @   s  e Zd Zedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZed	d
„ ƒZedd„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd „ ƒZed!d"„ ƒZed#d$„ ƒZed%d&„ ƒZed'd(„ ƒZed)d*„ ƒZed+d,„ ƒZed-d.„ ƒZed/d0„ ƒZed1d2„ ƒZed3d4„ ƒZed5d6„ ƒZed7d8„ ƒZed9d:„ ƒZ ed;d<„ ƒZ!ed=d>„ ƒZ"ed?d@„ ƒZ#edAdB„ ƒZ$edCdD„ ƒZ%edEdF„ ƒZ&edGdH„ ƒZ'edIdJ„ ƒZ(edKdL„ ƒZ)edMdN„ ƒZ*edOdP„ ƒZ+edQdR„ ƒZ,edSdT„ ƒZ-edUdV„ ƒZ.edWdX„ ƒZ/edYdZ„ ƒZ0ed[d\„ ƒZ1ed]d^„ ƒZ2ed_d`„ ƒZ3edadb„ ƒZ4edcdd„ ƒZ5ededf„ ƒZ6edgdh„ ƒZ7edidj„ ƒZ8edkdl„ ƒZ9edmdn„ ƒZ:edodp„ ƒZ;edqdr„ ƒZ<edsdt„ ƒZ=edudv„ ƒZ>edwdx„ ƒZ?edydz„ ƒZ@ed{d|„ ƒZAed}d~„ ƒZBedd€„ ƒZCedd‚„ ƒZDdƒS )„ÚItertoolsTestc              	   Ã   sV   t  t¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )N)r   é   é   ©ÚaitÚ
accumulateÚsrangeÚassertEqualÚnextÚassertRaisesÚStopAsyncIteration©ÚselfÚitÚk© r   ú@/tmp/pip-unpacked-wheel-n_uj7zou/aioitertools/tests/itertools.pyÚtest_accumulate_range_default   s
    
z+ItertoolsTest.test_accumulate_range_defaultc              	   Ã   s\   t jttjd}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )N©Úfunc©r   é   r   )	r   r   r   ÚoperatorÚmulr   r   r   r   r   r   r   r   Útest_accumulate_range_function   s
    z,ItertoolsTest.test_accumulate_range_functionc              	   Ã   sb   dd„ }t jt|d}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 Ó   s   | | S ©Nr   ©ÚaÚbr   r   r   r    "   s    z:ItertoolsTest.test_accumulate_range_coroutine.<locals>.mulr   r   r   )r   r    r   r   r   r   r   Útest_accumulate_range_coroutine    s    z-ItertoolsTest.test_accumulate_range_coroutinec              	   Ã   sf   dd„ }t j|ƒ tjd}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                   S  s   dV  dV  dV  d S ©Nr   r   r   r   r   r   r   r   Úgen-   s    z7ItertoolsTest.test_accumulate_gen_function.<locals>.genr   ©r   r   é   )r   r   r   r    r   r   r   r   ©r   r(   r   r   r   r   r   Útest_accumulate_gen_function+   s    z*ItertoolsTest.test_accumulate_gen_functionc              	   Ã   sl   dd„ }dd„ }t j|ƒ |d}dD ]}|  t  |¡I d H |¡ q$|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 Ó   s   | | S r"   r   r#   r   r   r   r    :   s    z8ItertoolsTest.test_accumulate_gen_coroutine.<locals>.mulc                   S  s   dV  dV  dV  d S r'   r   r   r   r   r   r(   =   s    z8ItertoolsTest.test_accumulate_gen_coroutine.<locals>.genr   r)   )r   r   r   r   r   r   )r   r    r(   r   r   r   r   r   Útest_accumulate_gen_coroutine8   s    z+ItertoolsTest.test_accumulate_gen_coroutinec                 Ã   s8   g }t  g ¡2 z3 d H W }| |¡ q6 |  |g ¡ d S r"   )r   r   Úappendr   ©r   ÚvaluesÚvaluer   r   r   Útest_accumulate_emptyH   s    z#ItertoolsTest.test_accumulate_emptyc              	   Ã   sX   t  tt¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )N)r   r   r   r   r   r
   )r   ÚchainÚslistr   r   r   r   r   r   r   r   r   Útest_chain_listsP   s
    zItertoolsTest.test_chain_listsc              	   Ã   sb   dd„ }t  t|ƒ ¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                  S  s   t dddƒD ]
} | V  qd S ©Nr   é	   ©Úrange©r   r   r   r   r(   Z   s    z/ItertoolsTest.test_chain_list_gens.<locals>.gen©r   r   r   r   r   r   r*   )r   r3   r4   r   r   r   r   r+   r   r   r   Útest_chain_list_gensX   s    z"ItertoolsTest.test_chain_list_gensc              	   Ã   sf   dd„ }t j t|ƒ g¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                  S  s   t dddƒD ]
} | V  qd S r6   r8   r:   r   r   r   r(   f   s    z3ItertoolsTest.test_chain_from_iterable.<locals>.genr;   )r   r3   Úfrom_iterabler4   r   r   r   r   r+   r   r   r   Útest_chain_from_iterabled   s    z&ItertoolsTest.test_chain_from_iterablec              	   ƒ   sn   dd„ ‰ ‡ fdd„}t j |ƒ ¡}dD ]}|  t  |¡I d H |¡ q&|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                  S  s   t dddƒD ]
} | V  qd S r6   r8   r:   r   r   r   r(   r   s    zKItertoolsTest.test_chain_from_iterable_parameter_expansion_gen.<locals>.genc                     s   t V  ˆ ƒ V  d S r"   ©r4   r   ©r(   r   r   Úparameters_genv   s    zVItertoolsTest.test_chain_from_iterable_parameter_expansion_gen.<locals>.parameters_genr;   )r   r3   r=   r   r   r   r   )r   rA   r   r   r   r@   r   Ú0test_chain_from_iterable_parameter_expansion_genp   s    z>ItertoolsTest.test_chain_from_iterable_parameter_expansion_genc              	   Ã   s\   t  tdƒd¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nr   r
   ))r   r   r   )r   r   r
   )r   r   r
   )r   r   r
   )r   Úcombinationsr9   r   r   r   r   r   r   r   r   Útest_combinations€   s
    zItertoolsTest.test_combinationsc              	   Ã   sX   t  td¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nr   ))r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   Úcombinations_with_replacementr4   r   r   r   r   r   r   r   r   Ú"test_combinations_with_replacementˆ   s
    z0ItertoolsTest.test_combinations_with_replacementc              
   Ã   sx   t dƒ}ddddddddddg
}t ||¡}dD ]}|  t |¡I d H |¡ q0|  t¡ t |¡I d H  W 5 Q R X d S )Né
   r   r   )r   r   r   r*   )r9   r   Úcompressr   r   r   r   ©r   ÚdataÚ	selectorsr   r   r   r   r   Útest_compress_list—   s    z ItertoolsTest.test_compress_listc              	   Ã   sl   d}t  dddg¡}t  ||¡}dD ]}|  t  |¡I d H |¡ q$|  t¡ t  |¡I d H  W 5 Q R X d S )NZabcdefghijklr   r   )r$   ÚdÚgÚj)r   ÚcyclerH   r   r   r   r   rI   r   r   r   Útest_compress_gen¢   s    zItertoolsTest.test_compress_genc                 Ã   s.   t  ¡ }dD ]}|  t  |¡I d H |¡ qd S )N)r   r   r   r
   ©r   Úcountr   r   r   r   r   r   Útest_count_bare­   s    zItertoolsTest.test_count_barec                 Ã   s0   t  d¡}dD ]}|  t  |¡I d H |¡ qd S )Né*   )rU   é+   é,   é-   rR   r   r   r   r   Útest_count_start³   s    
zItertoolsTest.test_count_startc                 Ã   s2   t  dd¡}dD ]}|  t  |¡I d H |¡ qd S )NrU   r
   )rU   rX   é0   é3   rR   r   r   r   r   Útest_count_start_step¹   s    z#ItertoolsTest.test_count_start_stepc                 Ã   s2   t jdd}dD ]}|  t  |¡I d H |¡ qd S )Néþÿÿÿ)Ústep)r   r]   éüÿÿÿiúÿÿÿrR   r   r   r   r   Útest_count_negative¿   s    z!ItertoolsTest.test_count_negativec                 Ã   s0   t  t¡}dD ]}|  t  |¡I d H |¡ qd S )N)r   r   r   r   r   r   r   r   )r   rP   r4   r   r   r   r   r   r   Útest_cycle_listÅ   s    
zItertoolsTest.test_cycle_listc                 Ã   s:   dd„ }t  |ƒ ¡}dD ]}|  t  |¡I d H |¡ qd S )Nc                   S  s   dV  dV  dV  d S ©Nr   r   rU   r   r   r   r   r   r(   Í   s    z)ItertoolsTest.test_cycle_gen.<locals>.gen)r   r   rU   r   r   rU   r   r   )r   rP   r   r   r+   r   r   r   Útest_cycle_genË   s    zItertoolsTest.test_cycle_genc                 Ã   s0   dd„ }t  t  |g ¡¡I d H }|  |g ¡ d S )Nc                 S   s   | dk S ©Nr   r   ©Úxr   r   r   ÚpredØ   s    z0ItertoolsTest.test_dropwhile_empty.<locals>.pred)r   ÚlistÚ	dropwhiler   )r   rg   Úresultr   r   r   Útest_dropwhile_emptyÖ   s    z"ItertoolsTest.test_dropwhile_emptyc              	   Ã   s`   dd„ }t  |t¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 S   s   | dk S rd   r   re   r   r   r   rg   à   s    z8ItertoolsTest.test_dropwhile_function_list.<locals>.pred©r   r
   ©r   ri   r   r   r   r   r   ©r   rg   r   r   r   r   r   Útest_dropwhile_function_listÞ   s    z*ItertoolsTest.test_dropwhile_function_listc              	   Ã   sj   dd„ }dd„ }t  ||ƒ ¡}dD ]}|  t  |¡I d H |¡ q"|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 S   s   | dk S rd   r   re   r   r   r   rg   ë   s    z7ItertoolsTest.test_dropwhile_function_gen.<locals>.predc                   S  s   dV  dV  dV  d S rb   r   r   r   r   r   r(   î   s    z6ItertoolsTest.test_dropwhile_function_gen.<locals>.gen©r   rU   ©r   ri   r   r   r   r   ©r   rg   r(   r   r   r   r   r   Útest_dropwhile_function_gené   s    z)ItertoolsTest.test_dropwhile_function_genc              	   Ã   s`   dd„ }t  |t¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 Ó   s   | dk S rd   r   re   r   r   r   rg   û   s    z9ItertoolsTest.test_dropwhile_coroutine_list.<locals>.predrl   rm   rn   r   r   r   Útest_dropwhile_coroutine_listù   s    z+ItertoolsTest.test_dropwhile_coroutine_listc              	   Ã   sj   dd„ }dd„ }t  ||ƒ ¡}dD ]}|  t  |¡I d H |¡ q"|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 Ó   s   | dk S rd   r   re   r   r   r   rg     s    z8ItertoolsTest.test_dropwhile_coroutine_gen.<locals>.predc                   S  s   dV  dV  dV  d S rb   r   r   r   r   r   r(   	  s    z7ItertoolsTest.test_dropwhile_coroutine_gen.<locals>.genrp   rq   rr   r   r   r   Útest_dropwhile_coroutine_gen  s    z*ItertoolsTest.test_dropwhile_coroutine_genc              	   Ã   s`   dd„ }t  |t¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 S   s   | d dkS ©Nr   r   r   re   r   r   r   rg     s    z:ItertoolsTest.test_filterfalse_function_list.<locals>.pred©r   r
   ©r   Úfilterfalser   r   r   r   r   rn   r   r   r   Útest_filterfalse_function_list  s    z,ItertoolsTest.test_filterfalse_function_listc              	   Ã   s`   dd„ }t  |t¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 Ó   s   | d dkS rv   r   re   r   r   r   rg   !  s    z;ItertoolsTest.test_filterfalse_coroutine_list.<locals>.predrw   rx   rn   r   r   r   Útest_filterfalse_coroutine_list  s    z-ItertoolsTest.test_filterfalse_coroutine_listc              	   Ã   sx   d}t  |¡}ddddgfdddgfddgffD ]}|  t  |¡I d H |¡ q0|  t¡ t  |¡I d H  W 5 Q R X d S )NÚaaabbar$   r%   ©r   Úgroupbyr   r   r   r   ©r   rJ   r   r   r   r   r   Útest_groupby_list*  s    
&zItertoolsTest.test_groupby_listc              	   Ã   s~   d}t j|tjd}ddddgfdddgfddgffD ]}|  t  |¡I d H |¡ q6|  t¡ t  |¡I d H  W 5 Q R X d S )NÚaAabBA©Úkeyr$   r   r%   r   ©r   r~   ÚstrÚlowerr   r   r   r   r   r   r   r   Útest_groupby_list_key4  s    &z#ItertoolsTest.test_groupby_list_keyc              	   Ã   s~   dd„ }t  |ƒ ¡}ddddgfdddgfddgffD ]}|  t  |¡I d H |¡ q6|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                  S  s   dD ]
} | V  qd S )Nr|   r   ©Úcr   r   r   r(   @  s    z+ItertoolsTest.test_groupby_gen.<locals>.genr$   r%   r}   r+   r   r   r   Útest_groupby_gen>  s    &zItertoolsTest.test_groupby_genc              	   Ã   s„   dd„ }t j|ƒ tjd}ddddgfdddgfddgffD ]}|  t  |¡I d H |¡ q<|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                  S  s   dD ]
} | V  qd S )Nr   r   rˆ   r   r   r   r(   L  s    z/ItertoolsTest.test_groupby_gen_key.<locals>.genr‚   r$   r   r%   r   r„   r+   r   r   r   Útest_groupby_gen_keyJ  s    &z"ItertoolsTest.test_groupby_gen_keyc                 Ã   s2   dd„ }t  |ƒ ¡2 z3 d H W }|  d¡ q6 d S )Nc                  S  s   t dƒD ]
} d V  qd S ©Nr   r8   )Ú_r   r   r   r(   X  s    z-ItertoolsTest.test_groupby_empty.<locals>.genz!No iteration should have happened)r   r~   Zfail)r   r(   r   r   r   r   Útest_groupby_emptyV  s    z ItertoolsTest.test_groupby_emptyc              	   Ã   sx   |   td¡$ t ddg¡2 z3 d H W }q6 W 5 Q R X |   td¡, t ddgdddd¡2 z3 d H W }qZ6 W 5 Q R X d S )Nzmust pass stop indexr   r   ztoo many argumentsr
   r   )ÚassertRaisesRegexÚ
ValueErrorr   Úislice)r   r   r   r   r   Útest_islice_bad_range_  s    "z#ItertoolsTest.test_islice_bad_rangec                 Ã   s>   g }t  tdƒd¡2 z3 d H W }| |¡ q6 |  |g ¡ d S )Né   r   )r   r‘   r9   r.   r   r/   r   r   r   Útest_islice_stop_zeroi  s    z#ItertoolsTest.test_islice_stop_zeroc              	   Ã   sX   t  td¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nr   ©r   r   ©r   r‘   r   r   r   r   r   r   r   r   r   Útest_islice_range_stopp  s
    z$ItertoolsTest.test_islice_range_stopc              	   Ã   s\   t  tdd d¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nr   r   rw   r–   r   r   r   r   Útest_islice_range_start_stepx  s
    z*ItertoolsTest.test_islice_range_start_stepc              	   Ã   sZ   t  tdd¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nr   r
   rl   r–   r   r   r   r   Útest_islice_range_start_stop€  s
    z*ItertoolsTest.test_islice_range_start_stopc              	   Ã   s\   t  tddd¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nr   r
   r   ©r   r–   r   r   r   r   Ú!test_islice_range_start_stop_stepˆ  s
    z/ItertoolsTest.test_islice_range_start_stop_stepc              	   Ã   s‚   dd„ }|ƒ }t  |d¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X t  |¡I d H ddgks~t‚d S )Nc                   S  s   dV  dV  dV  dV  d S ©Nr   r   r
   r   r   r   r   r   r   r(   ’  s    z/ItertoolsTest.test_islice_gen_stop.<locals>.genr   r•   r
   r   ©r   r‘   r   r   r   r   rh   ÚAssertionError©r   r(   Zgen_itr   r   r   r   r   Útest_islice_gen_stop  s    z"ItertoolsTest.test_islice_gen_stopc              	   Ã   sf   dd„ }t  |ƒ dd d¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                   S  s   dV  dV  dV  dV  d S rœ   r   r   r   r   r   r(   ¢  s    z5ItertoolsTest.test_islice_gen_start_step.<locals>.genr   r   )r   r   ©r   r‘   r   r   r   r   r+   r   r   r   Útest_islice_gen_start_step   s    z(ItertoolsTest.test_islice_gen_start_stepc              	   Ã   sd   dd„ }t  |ƒ dd¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                   S  s   dV  dV  dV  dV  d S rœ   r   r   r   r   r   r(   °  s    z5ItertoolsTest.test_islice_gen_start_stop.<locals>.genr   r
   rl   r¡   r+   r   r   r   Útest_islice_gen_start_stop®  s    z(ItertoolsTest.test_islice_gen_start_stopc              	   Ã   s„   dd„ }|ƒ }t  |ddd¡}dD ]}|  t  |¡I d H |¡ q"|  t¡ t  |¡I d H  W 5 Q R X t  |¡I d H dgks€t‚d S )Nc                   S  s   dV  dV  dV  dV  d S rœ   r   r   r   r   r   r(   ¾  s    z:ItertoolsTest.test_islice_gen_start_stop_step.<locals>.genr   r
   r   rš   r   r   rŸ   r   r   r   Útest_islice_gen_start_stop_step¼  s    z-ItertoolsTest.test_islice_gen_start_stop_stepc              	   Ã   sZ   t jtdd}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nr   ©Úr©r•   rw   )r   r   rl   )r
   r   )r
   r   )r   Úpermutationsr   r   r   r   r   r   r   r   r   Útest_permutations_listÌ  s
    z$ItertoolsTest.test_permutations_listc              	   Ã   sd   dd„ }t j|ƒ dd}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                   S  s   dV  dV  dV  d S ©Nr   r   r
   r   r   r   r   r   r(   Ö  s    z0ItertoolsTest.test_permutations_gen.<locals>.genr   r¥   r§   )r   r¨   r   r   r   r   r+   r   r   r   Útest_permutations_genÔ  s    z#ItertoolsTest.test_permutations_genc              	   Ã   s`   t  ddgddg¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nr   r   r   é   ©)r   r   )r   r¬   )r   r   )r   r¬   ©r   Úproductr   r   r   r   r   r   r   r   Útest_product_listá  s
    zItertoolsTest.test_product_listc              	   Ã   sh   dd„ }t  |dƒ|dƒ¡}dD ]}|  t  |¡I d H |¡ q |  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 S  s   | V  | d V  d S )Nr   r   re   r   r   r   r(   ë  s    z+ItertoolsTest.test_product_gen.<locals>.genr   r   r­   r®   r+   r   r   r   Útest_product_gené  s    zItertoolsTest.test_product_genc                 Ã   s6   t  d¡}dgd D ]}|  t  |¡I d H |¡ qd S )NrU   rG   )r   Úrepeatr   r   r   r   r   r   Útest_repeatõ  s    
zItertoolsTest.test_repeatc              	   Ã   s^   t  dd¡}dgd D ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )NrU   r“   )r   r²   r   r   r   r   r   r   r   r   Útest_repeat_limitû  s
    zItertoolsTest.test_repeat_limitc              	   Ã   sz   t d d… t dd … t g}dd„ }t ||¡}dD ]}|  t |¡I d H |¡ q2|  t¡ t |¡I d H  W 5 Q R X d S )Nr   r   c                  W   s
   d  | ¡S ©NÚ ©Újoin©Úargsr   r   r   Úconcat  s    z8ItertoolsTest.test_starmap_function_list.<locals>.concat©ZABZBCÚABC©r4   r   Ústarmapr   r   r   r   ©r   rJ   r»   r   r   r   r   r   Útest_starmap_function_list  s    z(ItertoolsTest.test_starmap_function_listc              	   Ã   sj   dd„ }dd„ }t  ||ƒ ¡}dD ]}|  t  |¡I d H |¡ q"|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                   s   s&   t d d… V  t dd … V  t V  d S ©Nr   r   r?   r   r   r   r   r(     s    z4ItertoolsTest.test_starmap_function_gen.<locals>.genc                  W   s
   d  | ¡S rµ   r·   r¹   r   r   r   r»     s    z7ItertoolsTest.test_starmap_function_gen.<locals>.concatr¼   ©r   r¿   r   r   r   r   ©r   r(   r»   r   r   r   r   r   Útest_starmap_function_gen  s    z'ItertoolsTest.test_starmap_function_genc              	   Ã   sz   t d d… t dd … t g}dd„ }t ||¡}dD ]}|  t |¡I d H |¡ q2|  t¡ t |¡I d H  W 5 Q R X d S )Nr   r   c                  ×   s
   d  | ¡S rµ   r·   r¹   r   r   r   r»   $  s    z9ItertoolsTest.test_starmap_coroutine_list.<locals>.concatr¼   r¾   rÀ   r   r   r   Útest_starmap_coroutine_list   s    z)ItertoolsTest.test_starmap_coroutine_listc              	   Ã   sj   dd„ }dd„ }t  ||ƒ ¡}dD ]}|  t  |¡I d H |¡ q"|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                   S  s&   t d d… V  t dd … V  t V  d S rÂ   r?   r   r   r   r   r(   /  s    z5ItertoolsTest.test_starmap_coroutine_gen.<locals>.genc                  ×   s
   d  | ¡S rµ   r·   r¹   r   r   r   r»   4  s    z8ItertoolsTest.test_starmap_coroutine_gen.<locals>.concatr¼   rÃ   rÄ   r   r   r   Útest_starmap_coroutine_gen-  s    z(ItertoolsTest.test_starmap_coroutine_genc                 Ã   s0   dd„ }t  t  |g ¡¡I d H }|  |g ¡ d S )Nc                 S   s   | dk S ©Nr
   r   re   r   r   r   rg   ?  s    z0ItertoolsTest.test_takewhile_empty.<locals>.pred)r   rh   Ú	takewhiler   )r   rg   r0   r   r   r   Útest_takewhile_empty=  s    z"ItertoolsTest.test_takewhile_emptyc              	   Ã   s`   dd„ }t  |t¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 S   s   | dk S rÈ   r   re   r   r   r   rg   G  s    z8ItertoolsTest.test_takewhile_function_list.<locals>.predr•   ©r   rÉ   r   r   r   r   r   rn   r   r   r   Útest_takewhile_function_listE  s    z*ItertoolsTest.test_takewhile_function_listc              	   Ã   sj   dd„ }dd„ }t  ||ƒ ¡}dD ]}|  t  |¡I d H |¡ q"|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                   S  s   dV  dV  dV  d S rª   r   r   r   r   r   r(   R  s    z6ItertoolsTest.test_takewhile_function_gen.<locals>.genc                 S   s   | dk S rÈ   r   re   r   r   r   rg   W  s    z7ItertoolsTest.test_takewhile_function_gen.<locals>.predr•   ©r   rÉ   r   r   r   r   ©r   r(   rg   r   r   r   r   r   Útest_takewhile_function_genP  s    z)ItertoolsTest.test_takewhile_function_genc              	   Ã   s`   dd„ }t  |t¡}dD ]}|  t  |¡I d H |¡ q|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                 Ó   s   | dk S rÈ   r   re   r   r   r   rg   b  s    z9ItertoolsTest.test_takewhile_coroutine_list.<locals>.predr•   rË   rn   r   r   r   Útest_takewhile_coroutine_list`  s    z+ItertoolsTest.test_takewhile_coroutine_listc              	   Ã   sj   dd„ }dd„ }t  ||ƒ ¡}dD ]}|  t  |¡I d H |¡ q"|  t¡ t  |¡I d H  W 5 Q R X d S )Nc                   s   s   dV  dV  dV  d S rª   r   r   r   r   r   r(   m  s    z7ItertoolsTest.test_takewhile_coroutine_gen.<locals>.genc                 Ó   s   | dk S rÈ   r   re   r   r   r   rg   r  s    z8ItertoolsTest.test_takewhile_coroutine_gen.<locals>.predr•   rÍ   rÎ   r   r   r   Útest_takewhile_coroutine_genk  s    z*ItertoolsTest.test_takewhile_coroutine_genc              
   Ã   sž   t  td ¡\}}td D ]J}t t  |¡t  |¡¡I d H \}}|  ||¡ |  ||¡ |  ||¡ q||fD ]*}|  t¡ t  |¡I d H  W 5 Q R X qnd S rd   )	r   Úteer4   ÚasyncioÚgatherr   r   r   r   )r   Úit1Úit2r   r$   r%   r   r   r   r   Útest_tee_list_two{  s    "zItertoolsTest.test_tee_list_twoc              
   Ã   s„   t jtd dd}td D ]4}tjdd„ |D ƒŽ I d H }|D ]}|  ||¡ q<q|D ]*}|  t¡ t  |¡I d H  W 5 Q R X qTd S )Nr   r   ©Únc                 S   s   g | ]}t  |¡‘qS r   ©r   r   ©Ú.0r   r   r   r   Ú
<listcomp>  s     z3ItertoolsTest.test_tee_list_six.<locals>.<listcomp>)	r   rÒ   r4   rÓ   rÔ   r   r   r   r   )r   Úitrsr   r0   r1   r   r   r   r   Útest_tee_list_sixˆ  s    zItertoolsTest.test_tee_list_sixc              
   Ã   s    dd„ }t  |ƒ ¡\}}dD ]J}t t  |¡t  |¡¡I d H \}}|  ||¡ |  ||¡ |  ||¡ q||fD ]*}|  t¡ t  |¡I d H  W 5 Q R X qpd S )Nc                   S  s   dV  dV  dV  dV  d S ©Nr   r   r7   é   r   r   r   r   r   r(   –  s    z+ItertoolsTest.test_tee_gen_two.<locals>.gen©r   r   r7   rá   )r   rÒ   rÓ   rÔ   r   r   r   r   )r   r(   rÕ   rÖ   r   r$   r%   r   r   r   r   Útest_tee_gen_two”  s    "zItertoolsTest.test_tee_gen_twoc              
   Ã   s†   dd„ }t j|ƒ dd}dD ]4}tjdd„ |D ƒŽ I d H }|D ]}|  ||¡ q>q|D ]*}|  t¡ t  |¡I d H  W 5 Q R X qVd S )Nc                   S  s   dV  dV  dV  dV  d S rà   r   r   r   r   r   r(   ©  s    z+ItertoolsTest.test_tee_gen_six.<locals>.genr   rØ   râ   c                 S   s   g | ]}t  |¡‘qS r   rÚ   rÛ   r   r   r   rÝ   ²  s     z2ItertoolsTest.test_tee_gen_six.<locals>.<listcomp>)r   rÒ   rÓ   rÔ   r   r   r   r   )r   r(   rÞ   r   r0   r1   r   r   r   r   Útest_tee_gen_six§  s    zItertoolsTest.test_tee_gen_sixc                 ƒ   sl   G dd„ dt ƒ‰ ‡ fdd„}dd„ }t |ƒ ¡\}}tj||ƒ||ƒddI d H }|D ]}|  |ˆ ¡ qVd S )	Nc                   @   s   e Zd ZdS )z;ItertoolsTest.test_tee_propagate_exception.<locals>.MyErrorN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   ÚMyError»  s   rè   c                     s   dV  dV  ˆ ‚d S )Nr   r   r   r   ©rè   r   r   r(   ¾  s    z7ItertoolsTest.test_tee_propagate_exception.<locals>.genc                 Ó   s$   d}| 2 z3 d H W }||7 }q6 |S rŒ   r   )r   rj   Úitemr   r   r   ÚconsumerÃ  s    z<ItertoolsTest.test_tee_propagate_exception.<locals>.consumerT)Zreturn_exceptions)Ú	Exceptionr   rÒ   rÓ   rÔ   ZassertIsInstance)r   r(   rë   rÕ   rÖ   r0   r1   r   ré   r   Útest_tee_propagate_exception¹  s    ýz*ItertoolsTest.test_tee_propagate_exceptionc              	   Ã   sh   t dƒ}t dƒ}t ||¡}dD ]}|  t |¡I d H |¡ q |  t¡ t |¡I d H  W 5 Q R X d S )Nr
   r“   ))r   r   )r   r   )r   r   rÈ   )Nr   ©r9   r   Úzip_longestr   r   r   r   )r   r$   r%   r   r   r   r   r   Útest_zip_longest_rangeÔ  s    z$ItertoolsTest.test_zip_longest_rangec              	   Ã   sr   dd„ }|ƒ }t dƒ}tj||dd}dD ]}|  t |¡I d H |¡ q*|  t¡ t |¡I d H  W 5 Q R X d S )Nc                   S  s   dV  dV  dV  dV  d S rà   r   r   r   r   r   r(   â  s    z5ItertoolsTest.test_zip_longest_fillvalue.<locals>.genr“   rU   )Ú	fillvalue))r   r   )r   r   )r7   r   )rá   r
   )rU   r   rî   ©r   r(   r$   r%   r   r   r   r   r   Útest_zip_longest_fillvalueà  s    z(ItertoolsTest.test_zip_longest_fillvaluec              	   Ã   sr   dd„ }|ƒ }t  d¡}t  ||¡}dD ]}|  t  |¡I d H |¡ q(|  td¡ t  |¡I d H  W 5 Q R X d S )Nc                   S  s   dV  dV  t dƒ‚d S )Nr   r   ú
fake error)rì   r   r   r   r   r(   ô  s    z5ItertoolsTest.test_zip_longest_exception.<locals>.genr“   ))r   r“   )r   r“   rô   )r   r²   rï   r   r   r   rì   rò   r   r   r   Útest_zip_longest_exceptionò  s    
z(ItertoolsTest.test_zip_longest_exceptionN)Erå   ræ   rç   r   r   r!   r&   r,   r-   r2   r5   r<   r>   rB   rD   rF   rL   rQ   rT   rY   r\   r`   ra   rc   rk   ro   rs   rt   ru   rz   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Æ   rÇ   rÊ   rÌ   rÏ   rÐ   rÑ   r×   rß   rã   rä   rí   rð   ró   rõ   r   r   r   r   r	      s  



































	
	



	
































r	   )rÓ   r   Zunittestr   Zaioitertoolsr   Zhelpersr   r4   r9   r   r	   r   r   r   r   Ú<module>   s   

