
    <e                        	 d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZmZ ej        s ej        d           ee	d          Zej                            ej                            e          dd          Zej                             ej        !                    e                    Zd	Z"d
Z#dZ$dZ%dZ& ej'        d          Z( G d dej)                  Z* G d dej)                  Z+ G d de+          Z, G d de+          Z- G d de+          Z. G d dej)                  Z/e0dk    r ej1                     dS dS )    N)libregrtest)support)	os_helper)utilssetupztest module requires subprocessgettotalrefcountz..z5[0-9]+:[0-9]+:[0-9]+ (?:load avg: [0-9]+\.[0-9]{2} )?            z
    from signal import SIGINT, raise_signal
    try:
        raise_signal(SIGINT)
    except ImportError:
        import os
        os.kill(os.getpid(), SIGINT)
    c                       e Zd Z	 d Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d)S )*ParseArgsTestCasec                 8   t          j                    5 }|                     t                    5  t	          j        |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     ||                                           d S N)r   captured_stderrassertRaises
SystemExitr   _parse_argsassertIngetvalue)selfargsmsgerrs       )/usr/lib/python3.11/test/test_regrtest.py
checkErrorzParseArgsTestCase.checkError6   s    $&& 	*#t/@/@/L/L 	* 	*#D)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*c3<<>>*****s4   A'AA'A	A'A	A''A+.A+c           	         dD ]}|                      |          5  t          j                    5 }|                     t                    5  t          j        |g           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |                     d|                                           d d d            n# 1 swxY w Y   d S )N)z-hz--helpoptzRun Python regression tests.)	subTestr   captured_stdoutr   r   r   r   r   r   )r   r   outs      r   	test_helpzParseArgsTestCase.test_help;   s   ! 	N 	NC#&& N N,.. 3#&&z223 3+SE2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 <cllnnMMM	N N N N N N N N N N N N N N N	N 	NsX   CB
A,	 B,A00B3A04B7CBC
B+CC		C	c                     t          j        ddg          }|                     |j        d           |                     dgd           |                     ddgd           d S )N	--timeoutz4.2g@expected one argumentfoozinvalid float value)r   r   assertEqualtimeoutr   r   nss     r   test_timeoutzParseArgsTestCase.test_timeoutC   sf    $k5%9::S)))'>???e,.CDDDDD    c                 d    t          j        dg          }|                     |j                   d S )N--wait)r   r   
assertTruewaitr*   s     r   	test_waitzParseArgsTestCase.test_waitI   s.    $hZ00     r-   c                     t          j        ddg          }|                     |j        d           |                     dgd           d S )Nz--worker-argsz[[], {}]r&   )r   r   r(   worker_argsr   r*   s     r   test_worker_argsz"ParseArgsTestCase.test_worker_argsM   sM    $oz%BCC444)+BCCCCCr-   c                     dD ]x}|                      |          5  t          j        |dg          }|                     |j        d           |                     |gd           d d d            n# 1 swxY w Y   yd S )N)z-S--startr   r'   r&   )r    r   r   r(   startr   r   r   r+   s      r   
test_startzParseArgsTestCase.test_startR   s    " 	@ 	@C#&& @ @ ,c5\::  5111'>???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@   A	A00A4	7A4	c                    t          j        dg          }|                     |j        d           t          j        dg          }|                     |j        d           t          j        dg          }|                     |j        d           t          j        dgdz            }|                     |j        d           t          j        g           }|                     |j        d           d S )N-v   z-vvvr
   	--verboser   )r   r   r(   verboser*   s     r   test_verbosezParseArgsTestCase.test_verboseY   s    $dV,,Q'''$fX..Q'''$k]33Q'''$k]Q%677Q'''$R((Q'''''r-   c                     dD ]_}|                      |          5  t          j        |g          }|                     |j                   d d d            n# 1 swxY w Y   `d S )N)-wz
--verbose2r   )r    r   r   r0   verbose2r9   s      r   test_verbose2zParseArgsTestCase.test_verbose2e       % 	- 	-C#&& - - ,cU33,,,- - - - - - - - - - - - - - -	- 	-   0AA	A	c                     dD ]_}|                      |          5  t          j        |g          }|                     |j                   d d d            n# 1 swxY w Y   `d S )N)-Wz
--verbose3r   )r    r   r   r0   verbose3r9   s      r   test_verbose3zParseArgsTestCase.test_verbose3k   rF   rG   c                     dD ]z}|                      |          5  t          j        |g          }|                     |j                   |                     |j        d           d d d            n# 1 swxY w Y   {d S )N)-q--quietr   r   )r    r   r   r0   quietr(   r@   r9   s      r   
test_quietzParseArgsTestCase.test_quietq   s    " 	0 	0C#&& 0 0 ,cU33)))  Q///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	0 	0s   AA22A6	9A6	c                     dD ]_}|                      |          5  t          j        |g          }|                     |j                   d d d            n# 1 swxY w Y   `d S )N)z-o	--slowestr   )r    r   r   r0   
print_slowr9   s      r   test_slowestzParseArgsTestCase.test_slowestx   s    $ 	/ 	/C#&& / / ,cU33.../ / / / / / / / / / / / / / /	/ 	/rG   c                     t          j        dg          }|                     |j                   t          j        dg          }|                     |j                   d S )Nz--headerr?   )r   r   r0   headerr*   s     r   test_headerzParseArgsTestCase.test_header~   sT    $j\22	"""$k]33	"""""r-   c                     dD ]_}|                      |          5  t          j        |g          }|                     |j                   d d d            n# 1 swxY w Y   `d S )N)-rz--randomizer   )r    r   r   r0   	randomizer9   s      r   test_randomizez ParseArgsTestCase.test_randomize   s    & 	. 	.C#&& . . ,cU33---. . . . . . . . . . . . . . .	. 	.rG   c                     t          j        ddg          }|                     |j        d           |                     |j                   |                     dgd           |                     ddgd           d S )Nz
--randseed12345i90  r&   r'   invalid int value)r   r   r(   random_seedr0   rZ   r   r*   s     r   test_randseedzParseArgsTestCase.test_randseed   sz    $lG%<==///%%%(?@@@u-/BCCCCCr-   c                 .   dD ]}|                      |          5  t          j        |dg          }|                     |j        d           |                     |gd           |                     |ddgd           d d d            n# 1 swxY w Y   d S )N)-f
--fromfiler   r'   r&   -sdon't go together)r    r   r   r(   fromfiler   r9   s      r   test_fromfilezParseArgsTestCase.test_fromfile   s    % 	I 	IC#&& I I ,c5\::  e444'>???eT 24GHHH	I I I I I I I I I I I I I I I	I 	Is   A"B		B	B	c                     dD ]_}|                      |          5  t          j        |g          }|                     |j                   d d d            n# 1 swxY w Y   `d S )N)z-x	--excluder   )r    r   r   r0   excluder9   s      r   test_excludezParseArgsTestCase.test_exclude       $ 	, 	,C#&& , , ,cU33
+++, , , , , , , , , , , , , , ,	, 	,rG   c                     dD ]x}|                      |          5  t          j        |g          }|                     |j                   |                     |ddgd           d d d            n# 1 swxY w Y   yd S )N)rd   z--singler   rb   r'   re   )r    r   r   r0   singler   r9   s      r   test_singlezParseArgsTestCase.test_single   s    # 	I 	IC#&& I I ,cU33	***dE 24GHHHI I I I I I I I I I I I I I I	I 	Ir;   c                    dD ]y}|                      |          5  t          j        |dg          }|                     |j        dg           |                     |gd           d d d            n# 1 swxY w Y   z|                     t          j        t          j	                   t          t          j	        d          5 }t          d|           t          d|           d d d            n# 1 swxY w Y   t          j                            t          j	                  }t          j        d	d
d|g          }|                     |j        ddg           d S )N)z-iz--ignorer   patternr&   w
matchfile1file
matchfile2-mmatch--ignorefile)r    r   r   r(   ignore_testsr   
addCleanupr   unlinkTESTFNopenprintospathabspathr   r   r+   fpfilenames        r   test_ignorezParseArgsTestCase.test_ignore   s   # 	@ 	@C#&& @ @ ,c9-=>>  9+>>>'>???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @
 		()*:;;;)"C(( 	)B,R((((,R((((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 7??9#344$dG&4h&@ A A&5	7 	7 	7 	7 	7s$   A
A11A5	8A5	#C00C47C4c                    dD ]y}|                      |          5  t          j        |dg          }|                     |j        dg           |                     |gd           d d d            n# 1 swxY w Y   zt          j        g d          }|                     |j        ddg           |                     t          j        t          j	                   t          t          j	        d          5 }t          d	|
           t          d|
           d d d            n# 1 swxY w Y   t          j                            t          j	                  }t          j        ddd|g          }|                     |j        g d           d S )N)rw   z--matchr   rq   r&   )rw   pattern1rw   pattern2r   r   rr   rs   rt   rv   rw   rx   --matchfile)rx   rs   rv   )r    r   r   r(   match_testsr   r{   r   r|   r}   r~   r   r   r   r   r   s        r   
test_matchzParseArgsTestCase.test_match   s'   " 	@ 	@C#&& @ @ ,c9-=>>  )==='>???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @
 $ &8 &8 &8 9 9*j)ABBB	()*:;;;)"C(( 	)B,R((((,R((((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 7??9#344$dG&3X&? @ @>>>	@ 	@ 	@ 	@ 	@s$   A
A11A5	8A5	4#D##D'*D'c                 Z   dD ]}|                      |          5  t          j        |dg          }|                     |j                   t          j        |dg          }|                     |j                   |                     |gd           d d d            n# 1 swxY w Y   d S )N)z-Gz
--failfastr   r=   rI   z#-G/--failfast needs either -v or -W)r    r   r   r0   failfastr   r9   s      r   test_failfastzParseArgsTestCase.test_failfast   s   % 	N 	NC#&& N N ,c4[99,,, ,c4[99,,,'LMMMN N N N N N N N N N N N N N N	N 	Ns   A8BB#	&B#	c                 R   dD ]}|                      |          5  t          j        |dg          }|                     |j        ddg           t          j        |dg          }|                     |j        dg           t          t          j                  }|                    d           t          j        |dg          }|                     |j        |           |                     |gd           |                     |d	gd
           t          j        |dg          }|                     |j        t          t          j                  dgz              t          j        |dg          }|                     |j        dg           d d d            n# 1 swxY w Y   d S )N)-uz--user   zgui,networkguinetworkzgui,none,networkzall,-guir&   r'   zinvalid resourcez
all,tzdatatzdataextralargefile)	r    r   r   r(   use_resourceslistALL_RESOURCESremover   )r   r   r+   expecteds       r   test_usezParseArgsTestCase.test_use   s     	G 	GC#&& G G ,c=-ABB  !1E93EFFF ,c3E-FGG  !1I;??? 9::&&& ,c:->??  !18<<<'>???e.@AAA !,c<-@AA  !1!%k&?!@!@H:!MO O O !,c3C-DEE  !14D3EFFF+G G G G G G G G G G G G G G G	G 	Gs   E2FF	!F	c                     dD ]x}|                      |          5  t          j        |dg          }|                     |j        d           |                     |gd           d d d            n# 1 swxY w Y   yd S )N)z-Mz
--memlimitr   4Gr&   )r    r   r   r(   memlimitr   r9   s      r   test_memlimitzParseArgsTestCase.test_memlimit   s    % 	@ 	@C#&& @ @ ,c4[99  d333'>???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@r;   c                     t          j        ddg          }|                     |j        t          j                            t          j        d                     | 	                    dgd           d S )Nz	--testdirr'   r&   )
r   r   r(   testdirr   r   joinr   SAVEDCWDr   r*   s     r   test_testdirzParseArgsTestCase.test_testdir   s_    $k5%9::RW\\)2De%L%LMMM'>?????r-   c                     dD ]_}|                      |          5  t          j        |g          }|                     |j                   d d d            n# 1 swxY w Y   `d S )N)z-Lz
--runleaksr   )r    r   r   r0   runleaksr9   s      r   test_runleakszParseArgsTestCase.test_runleaks   rF   rG   c                    dD ]T}|                      |          5  t          j        |dg          }|                     |j        d           t          j        |dg          }|                     |j        d           t          j        |dg          }|                     |j        d           t          j        |d	g          }|                     |j        d
           |                     |gd           |                     |dgd           |                     |dgd           |                     |dgd           d d d            n# 1 swxY w Y   Vd S )N)z-R--huntrleaksr   :)   r   
reflog.txtz6:)   r   r   z:3)r   r
   r   z6:3:leaks.log)r   r
   z	leaks.logr&   6z&needs 2 or 3 colon-separated argumentszfoo:zinvalid huntrleaks valuez6:foo)r    r   r   r(   
huntrleaksr   r9   s      r   test_huntrleaksz!ParseArgsTestCase.test_huntrleaks  s   ' 	L 	LC#&& L L ,c3Z88  0DEEE ,c4[99  0DEEE ,c4[99  0DEEE ,c?-CDD  0CDDD'>???c
 HJ J Jf/IJJJg0JKKKL L L L L L L L L L L L L L L	L 	Ls   D$EE	E	c                    dD ]}|                      |          5  t          j        |dg          }|                     |j        d           |                     |gd           |                     |dgd           |                     |ddgd	           |                     |d
dgd	           d d d            n# 1 swxY w Y   d S )N)z-jz--multiprocessr   2r	   r&   r'   r^   -Tre   0)r    r   r   r(   use_mpr   r9   s      r   test_multiprocessz#ParseArgsTestCase.test_multiprocess  s.   ) 	G 	GC#&& G G ,c3Z88  A...'>???e.ABBBc4 02EFFFc4 02EFFFG G G G G G G G G G G G G G G	G 	Gs   BB::B>	B>	c                     dD ]_}|                      |          5  t          j        |g          }|                     |j                   d d d            n# 1 swxY w Y   `d S )N)r   
--coverager   )r    r   r   r0   tracer9   s      r   test_coveragezParseArgsTestCase.test_coverage  s    % 	* 	*C#&& * * ,cU33)))* * * * * * * * * * * * * * *	* 	*rG   c           	      L   dD ]}|                      |          5  t          j        |dg          }|                     |j        t
          j                            t          j	        d                     | 
                    |gd           d d d            n# 1 swxY w Y   d S )N)z-Dz
--coverdirr   r'   r&   )r    r   r   r(   coverdirr   r   r   r   r   r   r9   s      r   test_coverdirzParseArgsTestCase.test_coverdir$  s    % 	@ 	@C#&& @ @ ,c5\::  !#i.@%!H!HJ J J'>???	@ @ @ @ @ @ @ @ @ @ @ @ @ @ @	@ 	@s   A1BB	B	c                     dD ]_}|                      |          5  t          j        |g          }|                     |j                   d d d            n# 1 swxY w Y   `d S )N)z-Nz--nocoverdirr   )r    r   r   assertIsNoner   r9   s      r   test_nocoverdirz!ParseArgsTestCase.test_nocoverdir,  s    ' 	/ 	/C#&& / / ,cU33!!"+.../ / / / / / / / / / / / / / /	/ 	/rG   c                 ,   dD ]}|                      |          5  t          j        |dg          }|                     |j        d           |                     |gd           |                     |dgd           d d d            n# 1 swxY w Y   d S )N)z-tz--thresholdr   1000i  r&   r'   r^   )r    r   r   r(   	thresholdr   r9   s      r   test_thresholdz ParseArgsTestCase.test_threshold2  s    & 	C 	CC#&& C C ,c6];;  t444'>???e.ABBB	C C C C C C C C C C C C C C C	C 	Cs   A!BB	B	c                    dD ]}|                      |          5  t          j        t          j                              5 }t          j        |g          }d d d            n# 1 swxY w Y   |                     |j                   |	                                }| 
                    d|           d d d            n# 1 swxY w Y   d S )N)-nz--nowindowsr   z)the --nowindows (-n) option is deprecated)r    
contextlibredirect_stderrioStringIOr   r   r0   	nowindowsr   r   )r   r   stderrr+   r   s        r   test_nowindowsz ParseArgsTestCase.test_nowindows:  sM   & 	P 	PC#&& P P/>> 8&$0#77B8 8 8 8 8 8 8 8 8 8 8 8 8 8 8---oo''I3OOOP P P P P P P P P P P P P P P	P 	Ps6   &B>A#B>#A''B>*A'+AB>>C	C	c                     dD ]_}|                      |          5  t          j        |g          }|                     |j                   d d d            n# 1 swxY w Y   `d S )N)z-F	--foreverr   )r    r   r   r0   foreverr9   s      r   test_foreverzParseArgsTestCase.test_foreverC  rl   rG   c                 4    |                      dgd           d S )Nz--xxxzusage:r   r   s    r   test_unrecognized_argumentz,ParseArgsTestCase.test_unrecognized_argumentI  s    	8,,,,,r-   c                     t          j        dg          }|                     |j                   |                     |j        d           d S )Nz--quir   )r   r   r0   rO   r(   r@   r*   s     r   test_long_option__partialz+ParseArgsTestCase.test_long_option__partialL  sF    $gY//!!!Q'''''r-   c                     t          j        ddg          }|                     |j                   |                     |j        d           |                     |j                   d S )NrN   ri   r   )r   r   r0   rO   r(   r@   rj   r*   s     r   test_two_optionsz"ParseArgsTestCase.test_two_optionsQ  s]    $i%=>>!!!Q'''
#####r-   c                 h    t          j        ddg          }|                     |j        d           d S )Nr7    )r   r   r(   r8   r*   s     r   #test_option_with_empty_string_valuez5ParseArgsTestCase.test_option_with_empty_string_valueW  s4    $i_552&&&&&r-   c                 h    t          j        dg          }|                     |j        dg           d S )Nr'   )r   r   r(   r   r*   s     r   test_argzParseArgsTestCase.test_arg[  s4    $eW--5'*****r-   c                     t          j        ddg          }|                     |j                   |                     |j        d           |                     |j        dg           d S )NrN   r'   r   )r   r   r0   rO   r(   r@   r   r*   s     r   test_option_and_argz%ParseArgsTestCase.test_option_and_arg_  sc    $i%788!!!Q'''5'*****r-   c                     t          j        g d          }|                     |j        d           |                     |j        ddg           d S )N)test_unaryopr=   
test_binopr>   r   r   )r   r   r(   r@   r   r*   s     r   test_arg_option_argz%ParseArgsTestCase.test_arg_option_arge  sT    $%I%I%IJJQ'''><"@AAAAAr-   c                 4    |                      dgd           d S )Nz--unknown-optionz(unrecognized arguments: --unknown-optionr   r   s    r   test_unknown_optionz%ParseArgsTestCase.test_unknown_optionj  s0    +,B	D 	D 	D 	D 	Dr-   N)+__name__
__module____qualname__r   r#   r,   r2   r5   r:   rA   rE   rK   rP   rT   rW   r[   r`   rg   rk   ro   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   1   s       + + +
N N NE E E! ! !D D D
@ @ @
( 
( 
(- - -- - -0 0 0/ / /# # #. . .D D DI I I, , ,I I I7 7 7$@ @ @,N N NG G G2@ @ @@ @ @
- - -L L L"G G G* * *@ @ @/ / /C C CP P P, , ,- - -( ( (
$ $ $' ' '+ + ++ + +B B B
D D D D Dr-   r   c            	       h    e Zd ZdZdZdZd ZddZd Zd Z	d	 Z
d
d
d
d
i d
dddf	dZd ZddZd ZdS )BaseTestCaser>   test_regrtest_ztest_[a-zA-Z0-9_]+c                    t           j                            t           j                            t                              | _        t          j                    | _        | 	                    t          j        | j                   d S r   )r   r   realpathdirname__file__r   tempfilemkdtemp
tmptestdirr{   r   rmtreer   s    r   setUpzBaseTestCase.setUpt  sV    w''(A(ABB"*,,	($/:::::r-   Nc                 &   |s$dt           j        z  }t           xj        dz  c_        |t          j        d          }| j        |z   }t
          j                            | j        |dz             }| 	                    t          j        |           	 t          |dd          5 }|                    |           d d d            n# 1 swxY w Y   nA# t          $ r4}t          j                    s|                     d|d	|            d }~ww xY w|S )
Nznoop%sr>   z
                    import unittest

                    class Tests(unittest.TestCase):
                        def test_empty_test(self):
                            pass
                z.pyxzutf-8)encodingzcannot write z: )r   TEST_UNIQUE_IDtextwrapdedentTESTNAME_PREFIXr   r   r   r   r{   r   r|   r~   writePermissionError	sysconfigis_python_buildskipTest)r   namecoder   r   excs         r   create_testzBaseTestCase.create_testz  s]    	-l99D''1,''<? $  D #d*w||DOTE\::	($///	dC'222 b               	 	 	,.. CtttSSABBB	 s<   C "C8C CC CC 
D/D		Dc                 ~    t          j        ||t           j                  }|s|                     |d|           |S )Nz not found in )research	MULTILINEfail)r   regexoutputrx   s       r   regex_searchzBaseTestCase.regex_search  sA    	%66 	>IIeeeVV<===r-   c                 v    t          j        d|z   t           j                  }|                     ||           d S )N^)r  compiler
  assertRegexr   r  r  s      r   
check_linezBaseTestCase.check_line  s5    
4%<66'''''r-   c                     dt           d| j        d}t          j        ||t          j                  }t          d |D                       S )Nr  z\[ *[0-9]+(?:/ *[0-9]+)*\] ()c              3   @   K   | ]}|                     d           V  dS )r>   Ngroup.0rx   s     r   	<genexpr>z4BaseTestCase.parse_executed_tests.<locals>.<genexpr>  s,      77uEKKNN777777r-   )
LOG_PREFIXTESTNAME_REGEXr  finditerr
  r   )r   r  r  parsers       r   parse_executed_testsz!BaseTestCase.parse_executed_tests  sO     JJ 3 3 35UFBL9977777777r-   r   Fc           	         t          |t                    r|g}t          |t                    r|g}t          |t                    r|g}t          |t                    r|g}t          |t                    r|g}t          |t                    r|g}|                     |          }|	r2|                     t	          |          t	          |          |           n|                     |||           d fd}|r" |d|          }|                     ||           |r" |d|          }|                     ||           |r" |d|          }|                     ||           |r" |d|          }|                     ||           |r |d|                                          }|                     ||           t          dz   }|                     ||           |                                D ],\  }}t          d	| d
| dz   }|                     ||           -|r" |d|          }|                     ||           t          |          t          |          z
  t          |          z
  t          |          z
  t          |          z
  t          |          z
  }|r6|d |          d}|s|s|dk    rd|z  }|                     ||           |
r|                     |d           g }|r|
                    d           n|r|r|
                    d           |
r|
                    d           t          ||||
|||f          s|
                    d           n|s|
                    d           d                    |          }|r|                     |d           d|z  }|                     |d|z             d S )Nc                     | dk    rdndS )Nr>   sr   r   )counts    r   pluralz1BaseTestCase.check_executed_tests.<locals>.plural  s    1**33",r-   c                     t          |          }d                    t          |                    }| | |          fz  }|d|d}|S )N z:\n    $)lenr   sorted)line_formattestsr%  namesr  r&  s        r   
list_regexz5BaseTestCase.check_executed_tests.<locals>.list_regex  sS    JJEHHVE]]++E5&&--"88E',uueee4ELr-   z%s test%s skippedz%s test%s failedz+%s test%s altered the execution environmentz%s test%s omittedz%s re-run test%sz'Re-running failed tests in verbose modezRe-running z in verbose mode \(matching: z\)z%s test%s run no testsz testz OK\.$r>   zAll %sz(Test suite interrupted by signal SIGINT.FAILUREzENV CHANGEDINTERRUPTEDzNO TEST RUNSUCCESS, zTests result: FAILUREzFAILURE then %szTests result: %s)
isinstancestrr!  r(   setr  keysr  itemsr*  appendanyr   )r   r  r-  skippedfailedenv_changedomittedrerunno_test_ranrZ   interruptedfail_env_changedexecutedr/  r  r  rx   goodresultr&  s                      @r   check_executed_testsz!BaseTestCase.check_executed_tests  s   
 eS!! 	GEgs## 	 iGfc"" 	XFk3'' 	(&-Kgs## 	 iGk3'' 	(&-K,,V44 	6S]]CJJ????Xuf555	- 	- 	-	 	 	 	 	  	+J2G<<EOOFE*** 	+J16::EOOFE*** 	+JL*, ,EOOFE*** 	+J2G<<EOOFE*** 	/J15::<<@@EOOFE***!KKEOOFE***${{}} / /e"%a4%a%aW\%a%a%aa.... 	+J7EEEOOFE***E

S\\)CKK7g,,!$[!1!12474D4DE 	+*.$$t=E )6 )dQhh 5(OOFE*** 	POOF$NOOO 	)MM)$$$$ 	)+ 	)MM-((( 	)MM-(((D&&+w!13 4 4 	%MM-(((( 	%MM)$$$6"" 	0OOF$;<<<&/F 2V ;<<<<<r-   c                     |                      d|          }t          |                    d                    }|                     d|cxk    odk    nc |           |S )NzUsing random seed ([0-9]+)r>   r   i )r  intr  r0   )r   r  rx   randseeds       r   parse_random_seedzBaseTestCase.parse_random_seed  sd    !!"?HHu{{1~~&&X111111118<<<r-   r   c                 "   |sd}d|vrt           j        |d<   t          j        |fd|t           j        d|}|j        |k    rLdt          |          d|j        d|j        d}|j        r|d	|j        z  z  }|                     |           |S )
Nr   r   T)universal_newlinesinputstdoutzCommand z failed with exit code z

stdout:
---
z
---
z
stderr:
---
%s---
)	
subprocessSTDOUTrunPIPE
returncoder5  rN  r   r  )r   r   rM  exitcodekwprocr   s          r   run_commandzBaseTestCase.run_command  s     	E2%,BxL~d $15$)%/_$ $ !#	$ $
 ?h&&& $iiii$+++?C { '  
 +& ' IIcNNNr-   c                 P    t           j        dddg|} | j        |fi |}|j        S )Nz-Xfaulthandlerz-I)sys
executablerW  rN  )r   r   rU  rV  s       r   
run_pythonzBaseTestCase.run_python(  s9    ndBTBt++++{r-   )NN)Nr   )r   r   r   r   r   r  r   r  r  r  r!  rF  rJ  rW  r\  r   r-   r   r   r   o  s        N&O*N; ; ;   <  ( ( (8 8 8 ;=R)+R#%2',%.3	\= \= \= \=|     8    r-   r   c                       e Zd Zd ZdS )CheckActualTestsc           	         	 g d}|                      |          }t          |                                          }t          j                            t          j        t          j                            t                              d          }t          t          j        |                    }| 
                    ||dz  dz  dd                    |                                                      d S )N)-Wd-E-bbrw   test.regrtest--list-testsztest*.py	   
   z+Unexpectedly low number of tests found in:
r3  )r   )r\  r*  
splitlinesr   r   r   globescaper   r   assertGreater)r   r   r  rough_number_of_tests_foundactual_testsuite_globrough_counted_test_py_filess         r   #test_finds_expected_number_of_testsz4CheckActualTests.test_finds_expected_number_of_tests/  s    	 KJJ&&&)&*;*;*=*=&>&># "T[9R9R-S-S-7!9 !9&)$)4I*J*J&K&K# 	66q8"< ?"ii(9(9(;(;<< ?  ? 	 	@ 	@ 	@ 	@ 	@r-   N)r   r   r   rn  r   r-   r   r^  r^  .  s(        @ @ @ @ @r-   r^  c                   |    e Zd Z	 dZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Z ej         ej                    d          d             Zd Z ej         ej                    d           ej        ej        dk    d          d                         Z ej        ej        dk    d          d             Z xZS )ProgramsTestCaser   c                 V    t                                                        fdt           j                  D              _        g d _        ddd j        z  g _         j                            d           t          j
        dk    r j                            d           d S d S )	Nc                 8    g | ]}                                 S r   r  r  indexr   s     r   
<listcomp>z*ProgramsTestCase.setUp.<locals>.<listcomp>R  s%    HHHUd&&((HHHr-   )r`  ra  rb  z-uallz-rwW--testdir=%s)r%   3600z-j4win32r   )superr   rangeNTESTr-  python_argsr   regrtest_argsextendrZ  platformr9  )r   	__class__s   `r   r   zProgramsTestCase.setUpN  s     IHHHeDJ6G6GHHH
///%v,t>@!!">???<7""%%d+++++ #"r-   c                 j    |                      |           |                     || j        d           d S )NT)rZ   )rJ  rF  r-  )r   r  s     r   check_outputzProgramsTestCase.check_output[  s9    v&&&!!&$*!EEEEEr-   c                 Z    |                      |          }|                     |           d S r   )r\  r  )r   r   r  s      r   	run_testszProgramsTestCase.run_tests_  s-    &&&!!!!!r-   c                     t           j                            | j        d          }g | j        || j        | j        }|                     |           d S )Nzregrtest.pyr   r   r   r   r}  r~  r-  r  r   scriptr   s      r   test_script_regrtestz%ProgramsTestCase.test_script_regrtestc  sR    dlM::L!L6LD,>LLtr-   c                 f    g | j         dd| j        | j        }|                     |           d S )Nrw   testr}  r~  r-  r  r   r   s     r   test_module_testz!ProgramsTestCase.test_module_testj  sN    2! 24 2 2#2&*j2tr-   c                 f    g | j         dd| j        | j        }|                     |           d S )Nrw   rc  r  r  s     r   test_module_regrtestz%ProgramsTestCase.test_module_regrtestp  N    2! 24 2 2#2&*j2tr-   c                 f    g | j         dd| j        | j        }|                     |           d S )Nrw   ztest.autotestr  r  s     r   test_module_autotestz%ProgramsTestCase.test_module_autotestv  r  r-   c                 j    d}g | j         d|| j        | j        }|                     |           d S )Nzfrom test import autotestz-cr  )r   r  r   s      r   test_module_from_test_autotestz/ProgramsTestCase.test_module_from_test_autotest|  sS    *2! 24 2 2#2&*j2tr-   c                     t           j                            | j        d          }g | j        || j        | j        }|                     |           d S )Nzautotest.pyr  r  s      r   test_script_autotestz%ProgramsTestCase.test_script_autotest  sR    dlM::L!L6LD,>LLtr-   z$run_tests.py script is not installedc                     t           j                            t          ddd          }|g| j        | j        }|                     |           d S )NToolsscriptszrun_tests.py)r   r   r   ROOT_DIRr~  r-  r  r  s      r   test_tools_script_run_testsz,ProgramsTestCase.test_tools_script_run_tests  sL     hNKK9+9dj9tr-   c                 d    |                      |          }|                     |j                   d S r   )rW  r  rN  )r   r   rV  s      r   	run_batchzProgramsTestCase.run_batch  s1    %%$+&&&&&r-   z test.bat script is not installedry  zWindows onlyc                    t           j                            t          ddd          }d| j        z  g}t          j                    dk    r|                    d           n_t          j                    dk    r|                    d           n2t          j                    d	         d
k    r|                    d           t          s|                    d            | j
        |g|| j        R   d S )Nr  buildbotztest.batrw  ARM64-arm64ARM-arm32r   64bit-x64z+d)r   r   r   r  r   r  machiner9  architecturePy_DEBUGr  r-  )r   r  	test_argss      r   test_tools_buildbot_testz)ProgramsTestCase.test_tools_buildbot_test  s    
 hZHH#do56	((X&&&&5((X&&&&"$$Q'722V$$$ 	#T"""v7	7DJ777777r-   c                 N   t           j                            t          d          }t           j                            |          s|                     d| d           dg}t          j                    dk    r|                    d           n_t          j                    dk    r|                    d           n2t          j	                    d	         d
k    r|                    d           t          r|                    d            | j        |g|| j        | j        R   d S )NzPCbuild\rt.batzFile "z" does not existrM   r  r  r  r  r   r  r  z-d)r   r   r   r  isfiler  r  r  r9  r  r  r  r~  r-  )r   r  rt_argss      r   test_pcbuild_rtz ProgramsTestCase.test_pcbuild_rt  s    h(9::w~~f%% 	=MM;6;;;<<<&((NN8$$$$5((NN8$$$$"$$Q'722NN6""" 	!NN4   vJJ$*<JtzJJJJJJr-   )r   r   r   r|  r   r  r  r  r  r  r  r  r  unittest
skipUnlessr   r  r  r  rZ  r  r  r  __classcell__)r  s   @r   rp  rp  F  s       
 E, , , , ,F F F" " "             X2244?A A A A' ' ' X2244;= =X0.AA8 8 BA= =8 X0.AAK K BAK K K K Kr-   rp  c                      e Zd Z	 d Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Z ej        ed          d             Z ej        ed          d             Zd Zd Zej        d             Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d  Z&d! Z'd" Z(d# Z)d$ Z*ej        d%             Z+d& Z,d' Z-d( Z.d) Z/d* Z0d+ Z1d, Z2d-S ).ArgsTestCasec                 <    ddd| j         z  g|} | j        |fi |S )Nrw   r  rw  )r   r\  )r   testargsrU  cmdargss       r   r  zArgsTestCase.run_tests  s4    $/!AMHMtw--"---r-   c                     t          j        d          }|                     d          }|                     d|          }||g} | j        |ddi}|                     |||           d S )Nz
            import unittest

            class FailingTest(unittest.TestCase):
                def test_failing(self):
                    self.fail("bug")
        okfailingr  rT  r	   r<  r   r   r  r  rF  )r   r  test_oktest_failingr-  r  s         r   test_failing_testzArgsTestCase.test_failing_test  s         ""4((''	'==,'333!!&%!EEEEEr-   c                    i }dD ]2}t          j        d|z            }|                     ||          ||<   3t          |                                          } | j        ddg|R  }|                     ||            | j        dg|R  }|                     |||d                     | j        | }|                     |||           d S )N)audior   a  
                        from test import support; support.requires(%r)
                        import unittest
                        class PassingTest(unittest.TestCase):
                            def test_pass(self):
                                pass
                    r   allz-uaudior   )r;  )r   r   r  r+  valuesr  rF  )r   r-  resourcer  
test_namesr  s         r   test_resourceszArgsTestCase.test_resources  s   , 		? 		?H? $ #$# $ $D #..x>>E(OOELLNN++
  e9j999!!&*555  	7J777!!&**/	*: 	" 	< 	< 	<  ,!!&**4 	" 	6 	6 	6 	6 	6r-   c                 F   t          j        d          }|                     d|          }|                     d|          }|                     |          }|                     d|          }t          |                    d                    }|                     dd|z  |          }|                     |          }|                     ||           |                     d|          }t          |                    d                    }|                     ||           d S )Nza
            import random
            print("TESTRANDOM: %s" % random.randint(1, 1000))
        randomrY   zTESTRANDOM: ([0-9]+)r>   z--randseed=%s)	r   r   r  r  rJ  r  rH  r  r(   )	r   r  r  r  rI  rx   test_random	randseed2test_random2s	            r   r  zArgsTestCase.test_random  s        $// d++))&11!!"96BB%++a..)) o&@$GG**622	H---!!"96BB5;;q>>**{33333r-   c           
           fdt          d          D             }t          j        }                     t          j        |           t          |d          5 }d }t          |d          D ]8\  }}d||t          |          |fz  }|r|d|z  z  }t          ||           |}9	 d d d            n# 1 swxY w Y    	                    d|          } 
                    ||           t          |d          5 }t          |d          D ],\  }}t          d	|d
t          |          d||           -	 d d d            n# 1 swxY w Y    	                    d|          } 
                    ||           t          |d          5 }|D ]}t          ||           	 d d d            n# 1 swxY w Y    	                    d|          } 
                    ||           t          |d          5 }|D ]}t          d|z  |           	 d d d            n# 1 swxY w Y    	                    d|          } 
                    ||           d S )Nc                 8    g | ]}                                 S r   rs  rt  s     r   rv  z.ArgsTestCase.test_fromfile.<locals>.<listcomp>  %    :::!!##:::r-   r   rr   r>   z00:00:%02i [%s/%s] %sz -- %s took 0 secrt   rc   [/z] zLib/test/%s.py)r{  r   r}   r{   r|   r~   	enumerater*  r   r  rF  )	r   r-  r   r   previousru  r  liner  s	   `        r   rg   zArgsTestCase.test_fromfile  s   ::::q:::
 #	((333 (C   	 BH(22    t/ %UT:; ;/(::Dd$$$$ 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  h77!!&%000 (C   	IB(22 I IteeeSZZZZ>RHHHHHI	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I h77!!&%000 (C   	%B % %d$$$$$%	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% h77!!&%000 (C   	8B 8 8&-B777778	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 h77!!&%00000sI   AB22B69B69>EEEF//F36F36HH!$H!c                     t           }|                     d|          }|                     |d          }|                     |||d           d S )Nsigintr  r   rT  Tr>  rA  )TEST_INTERRUPTEDr  r  rF  r   r  r  r  s       r   test_interruptedzArgsTestCase.test_interrupted5  sd    t44s33!!&$.2 	" 	4 	4 	4 	4 	4r-   c                       fdt          d          D             }  j        dg|R  }                     ||           d j        dt	          |          d}                     ||           d S )Nc                 8    g | ]}                                 S r   rs  rt  s     r   rv  z-ArgsTestCase.test_slowest.<locals>.<listcomp>>  r  r-   r
   rR   z10 slowest tests:
(?:- z: .*
){})r{  r  rF  r  r*  r  )r   r-  r  r  s   `   r   rT   zArgsTestCase.test_slowest<  s    ::::q:::4e444!!&%0000 '''U5 	&&&&&r-   c                 <   t           }|                     d|          }dD ]z}|                     |          5  |rdd|f}nd|f} | j        |ddi}|                     |||d	
           d}|                     ||           d d d            n# 1 swxY w Y   {d S )Nr  r  )FT)multiprocessingrR   -j2rT  r   Tr  z10 slowest tests:
)r  r  r    r  rF  r  )r   r  r  r  r   r  r  s          r   test_slowest_interruptedz%ArgsTestCase.test_slowest_interruptedF  s   t44, 	/ 	/Oo>> 
/ 
/" /'5DD'.D'<<<))&$26D * J J J /...
/ 
/ 
/ 
/ 
/ 
/ 
/ 
/ 
/ 
/ 
/ 
/ 
/ 
/ 
/	/ 	/s   ABB	B	c                     |                      d          }|                     d|          }|                     ||g           d}|                     ||           d S )Ncoverager   zLlines +cov% +module +\(path\)\n(?: *[0-9]+ *[0-9]{1,2}% *[^ ]+ +\([^)]+\)+)+)r  r  rF  r  )r   r  r  r  s       r   r   zArgsTestCase.test_coverageX  sb    
++d33!!&4&111B&&&&&r-   c                     |                      d          }|                     d|d          }|                     |d           d S )Nr1   r/   key)rM  zPress any key to continue)r  r  r  )r   r  r  s      r   r2   zArgsTestCase.test_waita  sG    ''$e<< ;<<<<<r-   c                     t          j        d          }|                     d|          }|                     d|d          }|                     ||gdz  |           d S )	NaL  
            import builtins
            import unittest

            class ForeverTester(unittest.TestCase):
                def test_run(self):
                    # Store the state in the builtins module, because the test
                    # module is reload at each run
                    if 'RUN' in builtins.__dict__:
                        builtins.__dict__['RUN'] += 1
                        if builtins.__dict__['RUN'] >= 3:
                            self.fail("fail at the 3rd runs")
                    else:
                        builtins.__dict__['RUN'] = 1
        r   r  r   r	   r  r
   r  r  r  s       r   r   zArgsTestCase.test_foreverg  sp         	55TA>>!!&4&(4!@@@@@r-   c                 &   |                      d|          }d}|                     t          j        |           |                     dd|dt
          j                  }|                     ||g|           d	}|                     |t          j
        |                     |d
|d}|                     ||           t          |          5 }|                                }	|                     ||	           d d d            d S # 1 swxY w Y   d S )Nr   r  r   r   z3:3:r	   )rT  r   r  z&beginning 6 repetitions
123456
......
z leaked [1, 1, 1] z, sum=3
)r  r{   r   r|   r  rO  rP  rF  r  r  ri  r   r~   read)
r   r  whatr  r   r  r  line2r   reflogs
             r   
check_leakzArgsTestCase.check_leak|  sQ   488	((333)*'1'8   : : 	!!&4&!>>>:	$00059TT444@eV$$$(^^ 	)rWWYYFMM%(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   +DD
D
zneed a debug buildc                 Z    t          j        d          }|                     |d           d S )Nz
            import unittest

            GLOBAL_LIST = []

            class RefLeakTest(unittest.TestCase):
                def test_leak(self):
                    GLOBAL_LIST.append(object())
        
referencesr   r   r  r   r  s     r   r   zArgsTestCase.test_huntrleaks  s6          	l+++++r-   c                 Z    t          j        d          }|                     |d           d S )Na  
            import os
            import unittest

            class FDLeakTest(unittest.TestCase):
                def test_leak(self):
                    fd = os.open(__file__, os.O_RDONLY)
                    # bug: never close the file descriptor
        zfile descriptorsr  r  s     r   test_huntrleaks_fd_leakz$ArgsTestCase.test_huntrleaks_fd_leak  s7          	011111r-   c                       fdt          d          D             }  j        dg|R  }                     |                                                                |           d S )Nc                 8    g | ]}                                 S r   rs  )r  ir   s     r   rv  z0ArgsTestCase.test_list_tests.<locals>.<listcomp>  s%    666!!##666r-   r   rd  )r{  r  r(   rstriprg  )r   r-  r  s   `  r   test_list_testszArgsTestCase.test_list_tests  sv    6666U1XX66677773355	  	  	  	  	 r-   c                 v   t          j        d          }|                     |          }d|z  d|z  g}|                     d|          }|                     |                                |           d|z  g}|                     ddd|          }|                     |                                |           d S )Nz
            import unittest

            class Tests(unittest.TestCase):
                def test_method1(self):
                    pass
                def test_method2(self):
                    pass
        r  z%s.Tests.test_method1z%s.Tests.test_method2z--list-casesrw   test_method1)r   r   r  r  r(   rg  )r   r  testnameall_methodsr  s        r   test_list_caseszArgsTestCase.test_list_cases  s         ###.. /9.9;99**,,k::: /9: $n (* * 	**,,k:::::r-   c                     d}|                      d|          }|g} | j        dg|R ddi}|                     |||d           d S )	Nz,import faulthandler; faulthandler._sigsegv()crash)r  r  r  rT  r	   Tr<  rZ   )r  r  rF  )r   r  
crash_testr-  r  s        r   test_crashedzArgsTestCase.test_crashed  sy     >%%7%>>
::::::!!&%
,0 	" 	2 	2 	2 	2 	2r-   c                     t          j        dt           j                  }d |                    |          D             S )Nz^(test[^ ]+).*ok$)flagsc                 8    g | ]}|                     d           S )r>   r  r  s     r   rv  z.ArgsTestCase.parse_methods.<locals>.<listcomp>  s"    CCC5ACCCr-   )r  r  r
  r  r  s      r   parse_methodszArgsTestCase.parse_methods  s9    
.blCCCCCENN6,B,BCCCCr-   c                    t          j        d          }g d}|                     |          }t          j        }|                     t          j        |           dd|z  g}t          |d          5 }|D ]}t          ||           	 d d d            n# 1 swxY w Y   | 	                    dd	||          }| 
                    |          }	d
dg}|                     |	|           d S )NV  
            import unittest

            class Tests(unittest.TestCase):
                def test_method1(self):
                    pass
                def test_method2(self):
                    pass
                def test_method3(self):
                    pass
                def test_method4(self):
                    pass
        r  test_method2test_method3test_method4r  r  %s.Tests.test_method3rr   rt   r=   ry   r  r  )r   r   r  r   r}   r{   r|   r~   r   r  r  r(   )
r   r  r  r  r   subsetr   r  r  methodss
             r   test_ignorefilezArgsTestCase.test_ignorefile  sT       7 7 7###.. #	((333 #h.	0
 (C   	%B % %d$$$$$%	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% nhII$$V,, .1&)))))s   2BBBc                 V   t          j        d          }g d}|                     |          }|                     d|          }|                     |          }|                     ||           t          j        }|                     t          j	        |           dd|z  g}t          |d          5 }|D ]}	t          |	|           	 d d d            n# 1 swxY w Y   |                     dd	||          }|                     |          }dd
g}|                     ||           d S )Nr	  r
  r  r=   r  r  rr   rt   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   test_matchfilezArgsTestCase.test_matchfile   s       7 7 7###.. h//$$V,,+... #	((333 #h.	0
 (C   	%B % %d$$$$$%	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% mXxHH$$V,, .1&)))))s   3CCCc                    t          j        d          }|                     |          }|                     |          }|                     ||g|           |                     d|d          }|                     ||g|d           d S )	Nz
            import unittest

            class Tests(unittest.TestCase):
                def test_env_changed(self):
                    open("env_changed", "w").close()
        r  )r=  --fail-env-changedr
   r  Tr=  rB  r  r   r  r  r  s       r   test_env_changedzArgsTestCase.test_env_changed)  s         ###.. ))!!&8*(!KKK  4hKK!!&8*(37 	" 	9 	9 	9 	9 	9r-   c                     t          j        d          }|                     |          }|                     d|d          }|                     ||g||di           d S )Na  
            import unittest

            class Tests(unittest.TestCase):
                def test_succeed(self):
                    return

                def test_fail_always(self):
                    # test that always fails
                    self.fail("bug")
        r  rC   r	   r  test_fail_alwaysr<  r?  r  r  s       r   test_rerun_failzArgsTestCase.test_rerun_fail<  s     
  
 
 ###..h;;!!&8*)1(DV9W 	" 	Y 	Y 	Y 	Y 	Yr-   c                     t          j        d          }|                     |          }|                     d|d          }|                     ||g|di           d S )Nax  
            import builtins
            import unittest

            class Tests(unittest.TestCase):
                def test_succeed(self):
                    return

                def test_fail_once(self):
                    if not hasattr(builtins, '_test_failed'):
                        builtins._test_failed = True
                        self.fail("bug")
        r  rC   r   r  test_fail_once)r?  r  r  s       r   test_rerun_successzArgsTestCase.test_rerun_successO  s         ###..h;;!!&8*)13C(D 	" 	F 	F 	F 	F 	Fr-   c                     t          j        d          }|                     |          }|                     d|t                    }|                     |||g|di           d S )Na  
            import unittest

            class ExampleTests(unittest.TestCase):
                @classmethod
                def setUpClass(self):
                    raise RuntimeError('Fail')

                def test_success(self):
                    return
        r  rC   r  ExampleTestsr  r   r   r  r  EXITCODE_BAD_TESTrF  r  s       r   #test_rerun_setup_class_hook_failurez0ArgsTestCase.test_rerun_setup_class_hook_failured       
  
 
 ###..h9JKK!!&(*2)1>(B 	" 	D 	D 	D 	D 	Dr-   c                     t          j        d          }|                     |          }|                     d|t                    }|                     |||g|di           d S )Na  
            import unittest

            class ExampleTests(unittest.TestCase):
                @classmethod
                def tearDownClass(self):
                    raise RuntimeError('Fail')

                def test_success(self):
                    return
        r  rC   r  r!  r  r"  r  s       r   &test_rerun_teardown_class_hook_failurez3ArgsTestCase.test_rerun_teardown_class_hook_failurex  r%  r-   c                     t          j        d          }|                     |          }|                     d|t                    }|                     |||g||i           d S )Nz
            import unittest

            def setUpModule():
                raise RuntimeError('Fail')

            class ExampleTests(unittest.TestCase):
                def test_success(self):
                    return
        r  rC   r  r  r"  r  s       r   $test_rerun_setup_module_hook_failurez1ArgsTestCase.test_rerun_setup_module_hook_failure       	  	 	 ###..h9JKK!!&(*2)18(< 	" 	> 	> 	> 	> 	>r-   c                     t          j        d          }|                     |          }|                     d|t                    }|                     |||g||i           d S )Nz
            import unittest

            def tearDownModule():
                raise RuntimeError('Fail')

            class ExampleTests(unittest.TestCase):
                def test_success(self):
                    return
        r  rC   r  r  r"  r  s       r   'test_rerun_teardown_module_hook_failurez4ArgsTestCase.test_rerun_teardown_module_hook_failure  r*  r-   c                     t          j        d          }|                     |          }|                     d|t                    }|                     |||g|di           d S )Nz
            import unittest

            class ExampleTests(unittest.TestCase):
                def setUp(self):
                    raise RuntimeError('Fail')

                def test_success(self):
                    return
        r  rC   r  test_successr  r"  r  s       r   test_rerun_setup_hook_failurez*ArgsTestCase.test_rerun_setup_hook_failure       	  	 	 ###..h9JKK!!&(*2)1>(B 	" 	D 	D 	D 	D 	Dr-   c                     t          j        d          }|                     |          }|                     d|t                    }|                     |||g|di           d S )Nz
            import unittest

            class ExampleTests(unittest.TestCase):
                def tearDown(self):
                    raise RuntimeError('Fail')

                def test_success(self):
                    return
        r  rC   r  r.  r  r"  r  s       r    test_rerun_teardown_hook_failurez-ArgsTestCase.test_rerun_teardown_hook_failure  r0  r-   c                     t          j        d          }|                     |          }|                     d|t                    }|                     |||g|di           d S )Na  
            import unittest

            class ExampleTests(unittest.IsolatedAsyncioTestCase):
                async def asyncSetUp(self):
                    raise RuntimeError('Fail')

                async def test_success(self):
                    return
        r  rC   r  r.  r  r"  r  s       r   #test_rerun_async_setup_hook_failurez0ArgsTestCase.test_rerun_async_setup_hook_failure  r0  r-   c                     t          j        d          }|                     |          }|                     d|t                    }|                     |||g|di           d S )Na  
            import unittest

            class ExampleTests(unittest.IsolatedAsyncioTestCase):
                async def asyncTearDown(self):
                    raise RuntimeError('Fail')

                async def test_success(self):
                    return
        r  rC   r  r.  r  r"  r  s       r   &test_rerun_async_teardown_hook_failurez3ArgsTestCase.test_rerun_async_teardown_hook_failure  r0  r-   c                     t          j        d          }|                     |          }|                     |ddd          }|                     ||g|           d S N
            import unittest

            class Tests(unittest.TestCase):
                def test_bug(self):
                    pass
        r  rw   
nosuchtestr   r  r@  r  r  s       r   test_no_tests_ranzArgsTestCase.test_no_tests_ran  sl         ###..$qII!!&8*(!KKKKKr-   c                     t          j        d          }|                     |          }|                     |d          }|                     ||g           d S )Nz
            import unittest

            class Tests(unittest.TestCase):
                def test_skipped(self):
                    self.skipTest("because")
        r  r   r  r  r  s       r   test_no_tests_ran_skipz#ArgsTestCase.test_no_tests_ran_skip  sc         ###..155!!&8*55555r-   c                     t          j        d          }|                     |          }|                     |          }|                     ||ddd          }|                     |||g||g           d S r8  r  )r   r  r  	testname2r  s        r   ,test_no_tests_ran_multiple_tests_nonexistentz9ArgsTestCase.test_no_tests_ran_multiple_tests_nonexistent  s         ###..$$$$//	)T<RSTT!!&8Y*?/7.C 	" 	E 	E 	E 	E 	Er-   c           	         t          j        d          }|                     |          }t          j        d          }|                     |          }|                     ||ddddd          }|                     |||g|g	           d S )
Nr9  r  z
            import unittest

            class Tests(unittest.TestCase):
                def test_other_bug(self):
                    pass
        rw   r:  test_other_bugr   r  r;  r  )r   r  r  
other_coder@  r  s         r   )test_no_test_ran_some_test_exist_some_notz6ArgsTestCase.test_no_test_ran_some_test_exist_some_not'  s         ###.._ &  
 $$*$55	)T< $&6   D D!!&8Y*?/7j 	" 	: 	: 	: 	: 	:r-   c                     t          j        d          }|                     |          }|                     d|d          }|                     ||g|gd           d S )Na  
            import _testcapi
            import gc
            import unittest

            @_testcapi.with_tp_del
            class Garbage:
                def __tp_del__(self):
                    pass

            class Tests(unittest.TestCase):
                def test_garbage(self):
                    # create an uncollectable object
                    obj = Garbage()
                    obj.ref_cycle = obj
                    obj = None
        r  r  r
   r  Tr  r  r  s       r   test_uncollectablezArgsTestCase.test_uncollectable>  s}        " ###.. 4hKK!!&8*/7j37 	" 	9 	9 	9 	9 	9r-   c                 *   t          j        d          }|                     |          }|                     dd|d          }|                     ||g|           |                     |t          j        d|z  t          j                             d S )	Naa  
            import time
            import unittest
            try:
                import faulthandler
            except ImportError:
                faulthandler = None

            class Tests(unittest.TestCase):
                # test hangs and so should be stopped by the timeout
                def test_sleep(self):
                    # we want to test regrtest multiprocessing timeout,
                    # not faulthandler timeout
                    if faulthandler is not None:
                        faulthandler.cancel_dump_traceback_later()

                    time.sleep(60 * 5)
        r  r  z--timeout=1.0r	   r  r  z%s timed out)	r   r   r  r  rF  r  r  r  r
  r  s       r   test_multiprocessing_timeoutz)ArgsTestCase.test_multiprocessing_timeoutX  s        $ ###..1MM!!&8*)1 	" 	3 	3 	3NX$=r|LL	N 	N 	N 	N 	Nr-   c                    t          j        d          }|                     |          }|                     dd|d          }|                     ||g|gd           |                     d	|           |                     d
|           d S )Na  
            import unittest
            import weakref
            from test.support import captured_stderr

            class MyObject:
                pass

            def weakref_callback(obj):
                raise Exception("weakref callback bug")

            class Tests(unittest.TestCase):
                def test_unraisable_exc(self):
                    obj = MyObject()
                    ref = weakref.ref(obj, weakref_callback)
                    with captured_stderr() as stderr:
                        # call weakref_callback() which logs
                        # an unraisable exception
                        obj = None
                    self.assertEqual(stderr.getvalue(), '')
        r  r  r=   r
   r  Tr  zWarning -- Unraisable exceptionzException: weakref callback bugr   r   r  r  rF  r   r  s       r   test_unraisable_excz ArgsTestCase.test_unraisable_excs  s         * ###.. 4dHqQQ!!&8*/7j37 	" 	9 	9 	9 	7@@@7@@@@@r-   c                    t          j        d          }|                     |          }|                     dd|d          }|                     ||g|gd           |                     d	|           |                     d
|           d S )Na[  
            import threading
            import unittest
            from test.support import captured_stderr

            class MyObject:
                pass

            def func_bug():
                raise Exception("bug in thread")

            class Tests(unittest.TestCase):
                def test_threading_excepthook(self):
                    with captured_stderr() as stderr:
                        thread = threading.Thread(target=func_bug)
                        thread.start()
                        thread.join()
                    self.assertEqual(stderr.getvalue(), '')
        r  r  r=   r
   r  Tr  z$Warning -- Uncaught thread exceptionzException: bug in threadrK  r  s       r   test_threading_excepthookz&ArgsTestCase.test_threading_excepthook  s         & ###.. 4dHqQQ!!&8*/7j37 	" 	9 	9 	9 	<fEEE0&99999r-   c                 J   t          j        d          }|                     |          }d}dD ]s}|                     |          5  d||g} | j        |ddi}|                     ||g|gd	
           |                     ||           d d d            n# 1 swxY w Y   td S )Na%  
            import sys
            import unittest
            from test import support

            class MyObject:
                pass

            def func_bug():
                raise Exception("bug in thread")

            class Tests(unittest.TestCase):
                def test_print_warning(self):
                    print("msg1: stdout")
                    support.print_warning("msg2: print_warning")
                    # Fail with ENV CHANGED to see print_warning() log
                    support.environment_altered = True
        r  zFtest_print_warning.*msg1: stdout\nWarning -- msg2: print_warning\nok\n)r=   rI   )optionr  rT  r
   Tr  )r   r   r  r    r  rF  r  )r   r  r  r  rP  cmdr  s          r   test_print_warningzArgsTestCase.test_print_warning  s&        $ ###.. # 	0 	0FV,, 0 0+VX>'9q99))&8*7?j;? * A A A   ///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	0 	0s   ABB	B	c                     t           j                            t          j                  }|                     |t          j         d           |                                r|                     d           d S d S )Nz not setzModified guard)r   environgetr   UNICODE_GUARD_ENVassertIsNotNoneisasciir  )r   guards     r   test_unicode_guard_envz#ArgsTestCase.test_unicode_guard_env  so    
u677Uu'>$H$H$HIII==?? 	, MM*+++++	, 	,r-   c                    t           j                            | j        d          }t          j        |           t           j                            | j        d          }t          |d                                           ||g}ddd| j        z  dg}|                     |           |D ]5}|                     t           j        	                    |          |           6d S )Ntest_python_123test_python_456wbrw   r  z--tempdir=%sz	--cleanup)
r   r   r   r   mkdirr~   closer\  assertFalseexists)r   r   r   r.  r  r  s         r   test_cleanupzArgsTestCase.test_cleanup  s    ',,t0ABB
7<<1BCCXt""$$$(#!DO3  	    	9 	9DRW^^D1148888	9 	9r-   c                    t           j        dk    rt          j                    }n;t           j        j        }|(t           j        j        }||                     d           d}	 |                    |           |                     | d|           n# t          $ r Y nw xY wt          j        d|d          }|                     |          }|                     dd	d
|t                    }|                     ||g|gd           d S )Nry  z#cannot get regrtest worker encodings	   byte:
z can decode non-ASCII bytes zf
            import sys
            # bytes which cannot be decoded from UTF-8
            nonascii = z]
            sys.stdout.buffer.write(nonascii)
            sys.stdout.buffer.flush()
        r  r  r=   z-j1r  Tr  )rZ  r  localegetencodingrN  r   
__stdout__r  decodeUnicodeDecodeErrorr   r   r  r  r#  rF  )r   r   nonasciir  r  r  s         r   test_mp_decode_errorz!ArgsTestCase.test_mp_decode_error  sU    <7"")++HHz*H>2#MM"HIII)	QOOH%%% MMXOO8OOPPPP " 	 	 	D	
    !        ###.. 4dE8):   < <!!&8**2,0 	" 	2 	2 	2 	2 	2s   #B 
B B N)3r   r   r   r  r  r  r  rg   r  rT   r  r   r2   r   r  r  r  r  r   r  r  r  r   cpython_onlyr  r  r  r  r  r  r  r$  r'  r)  r,  r/  r2  r4  r6  r<  r>  rA  rE  rG  rI  rL  rN  rR  rZ  rc  rk  r   r-   r   r  r    s*       . . .F F F 6 6 6:4 4 4..1 .1 .1`4 4 4' ' '/ / /$' ' '= = =A A A*) ) )( X#788, , 98, X#7882 2 982     ; ; ;4 2 2 2D D D"* "* "*H'* '* '*R9 9 9&Y Y Y&F F F*D D D(D D D(> > >&> > >&D D D&D D D&D D D&D D D&L L L6 6 6E E E: : :. 9 9 92N N N6A A AB: : :>&0 &0 &0P, , ,9 9 9!2 !2 !2 !2 !2r-   r  c                       e Zd Zd ZdS )	TestUtilsc                 &   |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d	          d
           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           d S )Nr   z0 msg&.>z1 msg{Gz?z10 msg      ?z1.5 secr>   z1.0 secx   z2 miny   z2 min 1 seci0*  z3 houri*  z3 hour 2 mini1*  z3 hour 1 sec)r(   r   format_durationr   s    r   test_format_durationzTestUtils.test_format_duration  s   .q11	! 	! 	!.t44	! 	! 	!.u55 	" 	" 	".s33"	$ 	$ 	$.q11"	$ 	$ 	$.v66 	" 	" 	".z::&	( 	( 	(.x88!	# 	# 	#./EFF'	) 	) 	).|<<'	) 	) 	) 	) 	)r-   N)r   r   r   rs  r   r-   r   rn  rn    s#        ) ) ) ) )r-   rn  __main__)2r   rh  r   re  os.pathr   r  r  rO  rZ  r   r   r   timer  r  r   r   test.supportr   test.libregrtestr   r   has_subprocess_supportSkipTesthasattrr  r   r   r   r   r  r   normpathr  r#  EXITCODE_ENV_CHANGEDEXITCODE_NO_TESTS_RANEXITCODE_INTERRUPTEDr   r  TestCaser   r   r^  rp  r  rn  r   mainr   r-   r   <module>r     s        				    				     



                     " " " " " " ) ) ) ) ) ) ) )% ?
(
=
>
>>73*++7<<114>>7??27++H5566E
    "8? $ 	 	 {D {D {D {D {D) {D {D {D|	| | | | |8$ | | |~@ @ @ @ @| @ @ @0oK oK oK oK oK| oK oK oKd[2 [2 [2 [2 [2< [2 [2 [2|) ) ) ) )! ) ) )0 zHMOOOOO r-   