
    ?_                     t    d dl Z d dlmZ d dlZd dlm Z ddlmZ g dZ	 e
d          Z G d de          ZdS )	    N)TestCase   )
async_test)ABC   c                       e Zd Zd Zed             Zed             Zed             Zed             Zed             Z	ed             Z
dS )	AsyncioTestc                 P    |                      t          j        t                     d S N)assertEqualaitasyncioaio)selfs    :lib/python3.11/site-packages/aioitertools/tests/asyncio.pytest_importzAsyncioTest.test_import   s     c*****    c                 r  K   d g d}g d}fd|D             }t          j        t          j        |                     d {V }|                     ||           fd|D             }g }t          j        |          2 3 d {V }|                    |           6 |                     ||           d S )Nc                 >   K   t          j        |           d {V  | S r   r   sleep)numberdurations     r   sleepyz-AsyncioTest.test_as_completed.<locals>.sleepy   s-      -)))))))))Mr   ))r   g333333?)   皙?)r	         ?)r   r   r	   c                     g | ]} | S  r!   .0pairr   s     r   
<listcomp>z1AsyncioTest.test_as_completed.<locals>.<listcomp>       333T664=333r   c                     g | ]} | S r!   r!   r"   s     r   r%   z1AsyncioTest.test_as_completed.<locals>.<listcomp>    r&   r   )r   listr   as_completedr   append)r   pairsexpectedfuturesresultsvaluer   s         @r   test_as_completedzAsyncioTest.test_as_completed   s     	 	 	 /..993333U333!1'!:!:;;;;;;;;(+++3333U333+G44 	" 	" 	" 	" 	" 	" 	"%NN5!!!! 5(+++++s   B c                   K   ddg}d |D             }|                      t          j                  5  t          j        t          j        |d                     d {V  d d d            n# 1 swxY w Y   d |D             }d}|                      t          j                  5  t          j        |d          2 3 d {V }|dz  }6 	 d d d            n# 1 swxY w Y   |                     |d           d S )	N)g      ?)r   c                 *    g | ]}t          j        | S r!   r   r#   argss     r   r%   z9AsyncioTest.test_as_completed_timeout.<locals>.<listcomp>*       :::D7=$':::r   r   )timeoutc                 *    g | ]}t          j        | S r!   r   r3   s     r   r%   z9AsyncioTest.test_as_completed_timeout.<locals>.<listcomp>.   r5   r   r   r   )assertRaisesr   TimeoutErrorr   r(   r   r)   r   )r   callsr-   r.   _s        r   test_as_completed_timeoutz%AsyncioTest.test_as_completed_timeout&   s      ::E:::w344 	C 	C(3+GSAAABBBBBBBBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C ;:E:::w344 	 	+GSAAA       a1 BA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	!$$$$$s/   /A--A14A1%C<C	CCCc                   K   d } |d          t          j         |d                    g}t          t           d          r1|                    t          j         |d                               n|                     |d                     t          j        |  d {V }|                     g d|           d S )Nc                 >   K   t          j        d           d {V  | S NMbP?r   args    r   fnz/AsyncioTest.test_gather_input_types.<locals>.fn7   -      -&&&&&&&&&Jr   r   r   create_taskr	   )r   r   r	   )r   ensure_futurehasattrr*   rE   r   gatherr   )r   rC   fnsresults       r   test_gather_input_typesz#AsyncioTest.test_gather_input_types5   s      	 	 	 r!uug+BBqEE2237M** 	JJw*22a55112222JJrr!uuz3'''''''F+++++r   c                   K   ddfdt          j        fdt          d          D             ddi d {V }|                     d           |                     g d|           t          j        fdt          d          D               d {V }|                     d           |                     g d|           d S )	Nr   c                 d   K   dz  k     rt          j        d           d {V  dz  | S )Nr   r@   r   )rB   countermax_counters    r   rC   z+AsyncioTest.test_gather_limited.<locals>.fnJ   sP      qLGW$$%-&&&&&&&&&qLGJr   c                 &    g | ]} |          S r!   r!   r#   irC   s     r   r%   z3AsyncioTest.test_gather_limited.<locals>.<listcomp>T   !    #=#=#=aBBqEE#=#=#=r   
   limitr   )
r   r   r   r	                  	   c                 &    g | ]} |          S r!   r!   rQ   s     r   r%   z3AsyncioTest.test_gather_limited.<locals>.<listcomp>Y   rS   r   )r   rH   ranger   )r   rJ   rN   rC   rO   s     @@@r   test_gather_limitedzAsyncioTest.test_gather_limitedE   s$     	 	 	 	 	 	 z#=#=#=#=599#=#=#=GQGGGGGGGGK(((777@@@ z#=#=#=#=599#=#=#=>>>>>>>	
 	
 	
 	777@@@@@r   c           	      H  K   d } |d          } |d          }t          j        ||||||d           d {V }|                     g d|            |d          } |d          }t          j        ||||||           d {V }|                     g d|           d S )Nc                 >   K   t          j        d           d {V  | S r?   r   rA   s    r   rC   z1AsyncioTest.test_gather_limited_dupes.<locals>.fna   rD   r   r   r   )rU   )r   r   r   r   r   r   )r   rH   r   )r   rC   fgrJ   s        r   test_gather_limited_dupesz%AsyncioTest.test_gather_limited_dupes_   s      	 	 	 BqEEBqEEz!Q1a!<<<<<<<<<+++V444BqEEBqEEz!Q1a33333333+++V44444r   c                   K    G d dt                     dfd	}|                               5  t          j         |dd           |d                     d {V  d d d            n# 1 swxY w Y   t          j         |dd           |d          d	           d {V }|                     |d
         d           |                     |d                    d S )Nc                       e Zd ZdS )<AsyncioTest.test_gather_with_exceptions.<locals>.MyExceptionN)__name__
__module____qualname__r!   r   r   MyExceptionrf   q   s        Dr   rj   Fc                 Z   K   t          j        |            d {V  |r |           | S r   r   )rB   failrj   s     r   rC   z3AsyncioTest.test_gather_with_exceptions.<locals>.fnt   sF      -$$$$$$$$$ '!k#&&&Jr   gMb`?T)rl   r@   )return_exceptionsr   r   )F)	Exceptionr8   r   rH   r   assertIsInstance)r   rC   rJ   rj   s      @r   test_gather_with_exceptionsz'AsyncioTest.test_gather_with_exceptionso   s     	 	 	 	 	) 	 	 		 	 	 	 	 	 {++ 	> 	>*RRD11122e99=========	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> zBu4   ""U))t
 
 
 
 
 
 
 
 
 	E***fQi55555s   0A..A25A2N)rg   rh   ri   r   r   r0   r<   rK   r^   rc   rp   r!   r   r   r   r      s        + + + , , Z,$ % % Z% , , Z, A A ZA2 5 5 Z5 6 6 Z6 6 6r   r   )r   unittestr   aioitertoolsr   aioitertools.asyncior   helpersr   slistr]   sranger   r!   r   r   <module>rw      s               " " " " " "      	qr6 r6 r6 r6 r6( r6 r6 r6 r6 r6r   