
    &h                         S SK r S SKJrJrJrJrJr  S SKJrJ	r	J
r
  S SKr " S S\ R                  5      r " S S\ R                  5      r\S:X  a  \ R                   " 5         gg)	    N)
FuncResulttmapWorkerQueueEmptySTOP)threadsSurface	transformc                   2    \ rS rSrS rS rS rS rS rSr	g)	WorkerQueueTypeTest	   c                 H   S nS n[        5       n[        U5      n[        U5      nUR                  US5        UR                  US5        UR                  5         UR	                  5         U R                  UR                  S5        U R                  UR                  S5        g )Nc                     U S-   $ N    xs    Q/var/www/auris/envauris/lib/python3.13/site-packages/pygame/tests/threads_test.pyfBWorkerQueueTypeTest.test_usage_with_different_functions.<locals>.f       q5L    c                     U S-   $ )N   r   r   s    r   f2CWorkerQueueTypeTest.test_usage_with_different_functions.<locals>.f2   r   r   r   r      )r   r   dowaitstopassertEqualresult)selfr   r   wqfrfr2s         r   #test_usage_with_different_functions7WorkerQueueTypeTest.test_usage_with_different_functions
   s{    		 ]]n
b!
c1
	
	A&Q'r   c                     g)zSTests function placement on queue and execution after blocking function completion.Nr   r$   s    r   test_doWorkerQueueTypeTest.test_do   s    r   c                    [        5       nU R                  [        UR                  5      S5        UR                   H"  nU R	                  UR                  5       5        M$     [        S5       H  nUR                  S U5        M     UR                  5         UR                   H"  nU R                  UR                  5       5        M$     U R                  UR                  R                  5       [        5        g)z$Ensure stop() stops the worker queuer      c                     U S-   $ r   r   r   s    r   <lambda>/WorkerQueueTypeTest.test_stop.<locals>.<lambda>C       AEr   N)r   assertGreaterlenpool
assertTrueis_aliveranger   r!   assertFalseassertIsqueuegetr   )r$   r%   tis       r   	test_stopWorkerQueueTypeTest.test_stop9   s    ]3rww<+AOOAJJL)  sAEE/1%  		AQZZ\*  	bhhllnd+r   c                 Z   [        S5      nUR                  UR                  5        / nUR                  UR                  S5        [        R
                  " S5        U R                  US   S5        UR                  5         U R                  UR                  S   R                  5       5        g )Nr   g      ?r   )r   r   
threadloopappendtimesleepr"   r!   r:   r6   r8   )r$   r%   ls      r   test_threadloop#WorkerQueueTypeTest.test_threadloopL   s     ^ 	bmm 
ahh

31q! 		 	,,./r   c                     [        5       n[        S5       H  nUR                  S U5        M     UR                  5         U R	                  [
        UR                  R                  5        UR                  5         g )Ni  c                     U S-   $ r   r   r   s    r   r1   /WorkerQueueTypeTest.test_wait.<locals>.<lambda>o   r3   r   )	r   r9   r   r    assertRaisesr   r<   
get_nowaitr!   )r$   r%   r?   s      r   	test_waitWorkerQueueTypeTest.test_waitg   sS    
 ]tAEE/1% 
	%!4!45
	r   r   N)
__name__
__module____qualname____firstlineno__r(   r,   r@   rH   rO   __static_attributes__r   r   r   r   r   	   s    ($b:,&06r   r   c                   >    \ rS rSrS rS rS rS rS rS r	S r
S	rg
)ThreadsModuleTestw   c                 ^    [         R                  " 5       nU R                  U[        5        U R	                  SUs=:*  =(       a    S:  Os  5        S n[        SSS5       Vs/ s H  n[        X34SS5      PM     nn[         R                  " X$5      nU R                  U[        5        gs  snf )zfEnsure benchmark_workers performance measure functions properly with both default and specified inputsr   @   c                 2    [         R                  " U S5        g )N)   r\   )r
   smoothscale)datas    r   smooth_scale_benchDThreadsModuleTest.test_benchmark_workers.<locals>.smooth_scale_bench   s    !!$
3r          N)r   benchmark_workersassertIsInstanceintr7   r9   r	   )r$   optimal_workersr_   r   	surf_databest_num_workerss         r   test_benchmark_workers(ThreadsModuleTest.test_benchmark_workersx   s     "335os3_11r12	4 6;2r25FG5FWaVQ+5F	G"445GS.4 Hs   #B*c                     [         R                  " S5        U R                  [         R                  [        5        [         R
                  " 5         g)z&Ensure init() sets up the worker queue   N)r   initrd   _wqr   quitr+   s    r   	test_initThreadsModuleTest.test_init   s*    Qgkk;7r   c                     [         R                  " S5        [         R                  " 5         U R                  [         R                  5        g)z(Ensure quit() cleans up the worker queuerl   N)r   rm   ro   assertIsNonern   r+   s    r   	test_quitThreadsModuleTest.test_quit   s(    Q'++&r   c                    S [        S5      p![        [        X5      5      n[        [        X5      5      nU R	                  X45        [        S5      nS n[        [        XeSS95      nU R                  [        S U 5       5      5        g )Nc                     U S-   $ r   r   r   s    r   r1   -ThreadsModuleTest.test_tmap.<locals>.<lambda>   s    q1ur   d   c                     SS-  $ )Nr   r   r   r   s    r   r1   rx      s    1q5r   F)stop_on_errorc              3   (   #    U  H  oS L v   M
     g 7fNr   .0r   s     r   	<genexpr>.ThreadsModuleTest.test_tmap.<locals>.<genexpr>   s     8x!Ixs   )r9   listr   mapr"   r7   all)r$   funcr^   tmappedmappeddata2always_exceptstmapped2s           r   	test_tmapThreadsModuleTest.test_tmap   st     %eCjdtD'(c$o&) c
(^%HI 	8x889r   c                 F   U R                  5         [        S/ SQ5      n[        S/ SQ/ SQ5      n[        S/ SQ/ SQ5      n[        S/ SQ/ SQ5      nU R                  / SQU5        U R                  / SQU5        U R                  / SQU5        U R                  / SQU5        g)	z+Using a None as func and multiple sequencesN)r   r   r      )   !   ,   7   )r   r   r   r   B   )r   r   r   r      )r   r   r   r   r   r   r   r   )r   r   r   r   )Nr   )r   r   r   r   )r   N)failr   r"   )r$   resres2res3res4s        r   0todo_test_tmap__None_func_and_multiple_sequencesBThreadsModuleTest.todo_test_tmap__None_func_and_multiple_sequences   s    		4&D,(89D,(<=D/+;<s+=tDI4PH$Or   c                     [        S5      n[        S USSS9u  p#UR                  5         S U 5       nU R                  [	        U5      [	        U5      5        g )Ni  c                     U $ r}   r   r   s    r   r1   3ThreadsModuleTest.test_tmap__wait.<locals>.<lambda>   s    Qr   r   F)num_workersr    c              3   8   #    U  H  oR                   v   M     g 7fr}   )r#   r~   s     r   r   4ThreadsModuleTest.test_tmap__wait.<locals>.<genexpr>   s     (1hhs   )r9   r   r    r"   r   )r$   rr%   resultsr2s        r   test_tmap__wait!ThreadsModuleTest.test_tmap__wait   sH    $K;quE
	((a$r(+r   c                   ^ [        S 5      nU" S5        U R                  UR                  S5        U R                  UR                  S5        [        S5      mU4S jn[        U5      nU" S5        U R                  UR                  T5        g)z:Ensure FuncResult sets its result and exception attributesc                     U S-   $ r   r   r   s    r   r1   3ThreadsModuleTest.test_FuncResult.<locals>.<lambda>   s    !a%r   r   r   zno exception should be raisedrastc                    > Ter}   r   )sdf	exceptions    r   r   ,ThreadsModuleTest.test_FuncResult.<locals>.x   s    Or   N)r   r"   r#   rs   r   
ValueErrorr;   )r$   r&   r   r   s      @r   test_FuncResult!ThreadsModuleTest.test_FuncResult   st     (
1A& 	",,(GHv&		 ]
4bllI.r   r   N)rQ   rR   rS   rT   ri   rp   rt   r   r   r   r   rU   r   r   r   rW   rW   w   s'    52':@P,/r   rW   __main__)unittestpygame.threadsr   r   r   r   r   pygamer   r	   r
   rE   TestCaser   rW   rQ   mainr   r   r   <module>r      s[     E E . . k(++ k\q/)) q/l zMMO r   