
    
9j                    R    S SK Jr  S SKrS SKrS SKr " S S5      rS rSS jrS rg)	    )annotationsNc                      \ rS rSrS rSrg)QuietTestRunner	   c                @    [         R                  " 5       nU" U5        U$ N)unittest
TestResult)selfsuiteresults      Q/home/wildlama/miniconda3/lib/python3.13/site-packages/cupy/testing/_condition.pyrunQuietTestRunner.run   s    $$&f     N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r   	   s    r   r   c                4   ^ ^^ SSK mT T:  d   eUUU 4S jnU$ )a  Decorator for multiple trial of the test case.

The decorated test case is launched multiple times.
The case is judged as passed at least specified number of trials.
If the number of successful trials exceeds `min_success`,
the remaining trials are skipped.

Args:
    times(int): The number of trials.
    min_success(int): Threshold that the decorated test
        case is regarded as passed.

r   Nc                   >^  TR                   R                  SS9[        R                  " T 5      U UU4S j5       5       nU$ )Nzrepeat is not thread-safe)reasonc            	       >^ ^^^^^	^
 [        T 5      S:  d   eT S   m[        T[        R                  5      (       d   eSm
Sm/ m	UUU	U
4S jn[	        T5       GH$  n[        R
                  " 5       n[        T5      " TR                  5      mUR                  [        R                  " U UUU4S jTR                  TR                  S95        [        5       R                  U5      n[        UR                  5      S:X  a"  TR                  UR                  S   S   5        O1UR!                  5       (       a  T
S-  m
OT	R#                  U5        TS-  mT
T:  a  TR%                  S5          g TTT-
  :  d  GM  U" 5           g    U" 5         g )Nr   c                   > SR                  TT5      n [        T5      S:  aM  TS   nUR                  UR                  -   n[        U5      S:  a   SR	                  S U 5       5      nU SU-   -  n TR                  U 5        g )Nz
Fail: {}, Success: {}r   
c              3  *   #    U  H	  oS    v   M     g7f)   Nr   ).0fails     r   	<genexpr>urepeat_with_success_at_least.<locals>._repeat_with_success_at_least.<locals>.wrapper.<locals>.fail.<locals>.<genexpr>9   s     +EGs   z

The first error message:
)formatlenfailureserrorsjoinr!   )msgfirsterrserr_msgfailure_counterinstanceresultssuccess_counters       r   r!   brepeat_with_success_at_least.<locals>._repeat_with_success_at_least.<locals>.wrapper.<locals>.fail2   sz    /66#_6w<!##AJE >>ELL8D4y1}"&))+E+E"E?'IIc"r   c                 "   > T" T/T SS  Q70 TD6$ )Nr   r   )argsfinskwargss   r   <lambda>frepeat_with_success_at_least.<locals>._repeat_with_success_at_least.<locals>.wrapper.<locals>.<lambda>D   s    # ;QR ;F ;r   )setUptearDownr   T)r%   
isinstancer	   TestCaserange	TestSuitetype_testMethodNameaddTestFunctionTestCaser9   r:   r   r   skippedskipTestwasSuccessfulappend
assertTrue)r3   r6   r!   _r   r   r-   r5   r.   r/   r0   r4   min_successtimess   ``    @@@@@r   wrapperTrepeat_with_success_at_least.<locals>._repeat_with_success_at_least.<locals>.wrapper(   sW    t9q= =AwHh(9(9::::OOG	# 	# 5\ **, 8nX%=%=>--;!ii!$/0 )*..u5v~~&!+
 %%fnnQ&7&:;))++#q(ONN6*#q(O"k1''-"U[%88F9 ": Fr   )markthread_unsafe	functoolswraps)r4   rK   rI   pytestrJ   s   ` r   _repeat_with_success_at_leastCrepeat_with_success_at_least.<locals>._repeat_with_success_at_least#   sD    
 
	"	"*E	"	F		0	 
 
G0	b r   )rQ   )rJ   rI   rR   rQ   s   `` @r   repeat_with_success_at_leastrT      s$     K8r )(r   c                    Uc  [        X 5      $ [        [        [        R                  R                  SS5      5      5      nU(       a  U OUn[        X35      $ )a  Decorator that imposes the test to be successful in a row.

Decorated test case is launched multiple times.
The case is regarded as passed only if it is successful
specified times in a row.

.. note::
    In current implementation, this decorator grasps the
    failure information of each trial.

Args:
    times(int): The number of trials in casual test.
    intensive_times(int or None): The number of trials in more intensive
        test. If ``None``, the same number as `times` is used.
CUPY_TEST_CASUAL0)rT   boolintosenvironget)rJ   intensive_timescasual_testtimes_s       r   repeatr`   _   sH      +E99s2::>>*<cBCDK!UF'77r   c                    [        U S5      $ )aK  Decorator that imposes the test to be successful at least once.

Decorated test case is launched multiple times.
The case is regarded as passed if it is successful
at least once.

.. note::
    In current implementation, this decorator grasps the
    failure information of each trial.

Args:
    times(int): The number of trials.
r   )rT   )rJ   s    r   retryrb   w   s     (q11r   r   )	
__future__r   rO   rZ   r	   r   rT   r`   rb   r   r   r   <module>rd      s,    "  	  K)\802r   