
    hg                         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 d dlmZ d dlmZ ej        Z G d d	ej                  Zed
k    r ej                     dS dS )    N)support)import_helper)	os_helper)script_helper)socket_helper)warnings_helperc                   |   e Zd Zed             Zed             Zd Zd Zd Zd Z	 e
j        d          d             Zd	 Zd
 Zd Zd Z ej                    d             Z ej                    d             Z ej                    d             Zd Z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- G d' d(          Z. G d) d*          Z/d+ Z0d, Z1d- Z2 e
j3         e4e5d.          o e4e5d/          d0           ej                    d1                         Z6 ej7                    d=d3            Z8d4 Z9d5 Z:d6 Z; e
j<        ej=        d7           e
j<        ej>        d8          d9                         Z?d: Z@d; ZAd< ZBd2S )>TestSupportc                     t          t          j                  }t          j        dd          | _        t          j        dd          | _        t          t          j                  |dz   k    sJ d S )Nztest.support.warnings_helperz.*used in test_support.*)likeztest.test_supportz!.*You should NOT be seeing this.*   )lenwarningsfiltersr   ignore_deprecations_from_warnings_helper_token_test_support_tokenclsorig_filter_lens     (/usr/lib/python3.11/test/test_support.py
setUpClasszTestSupport.setUpClass   s}    h.//%,%E*1K&
 &
 &
" #*"B&I#
 #
 #
 8#$$!(;;;;;;;    c                     t          t          j                  }t          j        | j        | j                   t          t          j                  |dz
  k    sJ d S )Nr   )r   r   r   r   clear_ignored_deprecationsr   r   r   s     r   tearDownClasszTestSupport.tearDownClass&   s\    h.//*&#	
 	
 	
 8#$$!(;;;;;;;r   c                    t          j        d          5 }t          j                     t          j        dt
                     d |D             }ddd           n# 1 swxY w Y   |                     t          |          d|           dS )z9Test support.ignore_deprecations_from() silences warningsT)recordzYou should NOT be seeing this.c                 6    g | ]}t          |j                  S  strmessage.0ws     r   
<listcomp>zDTestSupport.test_ignored_deprecations_are_silent.<locals>.<listcomp>4   s     ===1AI===r   Nr   )r   catch_warningsr   _warn_about_deprecationwarnDeprecationWarningassertEqualr   )selfwarning_objsmessagess      r   $test_ignored_deprecations_are_silentz0TestSupport.test_ignored_deprecations_are_silent/   s    $D111 	>\3555M:<NOOO=====H	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	X844444s   :AA #A c                     t          j        d           |                     t          j        t           j        d           d S )Nftplibfoo)r   import_moduleassertRaisesunittestSkipTestr-   s    r   test_import_modulezTestSupport.test_import_module7   sB    #H---(+'5u	> 	> 	> 	> 	>r   c                 .    t          j        d           d S )Nr2   )r   import_fresh_moduler8   s    r   test_import_fresh_modulez$TestSupport.test_import_fresh_module<   s    )(33333r   c                     |                      t          j        | d          | j                   |                     t
          j        t          j        | d           d S )Ntest_get_attributer3   )r,   r   get_attributer>   r5   r6   r7   r8   s    r   r>   zTestSupport.test_get_attribute?   sV    .t5IJJ/	1 	1 	1(+W-BD%PPPPPr   zfailing buildbotsc                 h    |                      t          j                    t          j                   d S N)r,   r   get_original_stdoutsysstdoutr8   s    r   test_get_original_stdoutz$TestSupport.test_get_original_stdoutD   s)    466
CCCCCr   c                     dd l }|                     dt          j                   t	          j        d           |                     dt          j                   d S )Nr   sched)rG   assertInrC   modulesr   unloadassertNotIn)r-   rG   s     r   test_unloadzTestSupport.test_unloadH   sP    gs{+++W%%%#+.....r   c                 8   t          t          dd          5 }	 d d d            n# 1 swxY w Y   t          j        t                     |                     t
          j                            t                               t          j        t                     d S )Nr&   utf-8encoding)openTESTFNr   unlinkassertFalseospathexists)r-   fs     r   test_unlinkzTestSupport.test_unlinkN   s    &#000 	A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   //000     s   &**c                    t           j        dz   }t          j                            |d          }t          j        |           t          j        |           t          j        |           |                     t          j                            |                     t          j
        t          dd          5  t          j        |           d d d            n# 1 swxY w Y   t          j        |           t          j        |           t          j        |t          j        t          j        z             t          j
        t          dd          5  t          j        |           d d d            n# 1 swxY w Y   |                     t          j                            |                     t          j        |           t          j        |           t          j        |d           t          j
        t          dd          5  t          j        |           d d d            n# 1 swxY w Y   |                     t          j                            |                     d S )Ndsubdirverboser   )r   rR   rU   rV   joinmkdirrmtreerT   rW   r   	swap_attrchmodstatS_IRUSRS_IXUSR)r-   dirpath
subdirpaths      r   test_rmtreezTestSupport.test_rmtreeU   s   "S(W\\'844


!!!00111w	155 	& 	&W%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	

$,t|3444w	155 	& 	&W%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&00111


!w	155 	& 	&W%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&0011111s6   9CC!CE55E9<E9
H++H/2H/c                    t           dz   }t          |dd          5 }t          d|           d d d            n# 1 swxY w Y   t          j                            dt          j                   t          j	                     	 t          t                     }|                     t           t          j                   t          j        t                      |                     t           t          j                   t          j        d= t!          j        |           t!          j        d           d S # t          j        d= t!          j        |           t!          j        d           w xY w)	Nz.pyr&   rN   rO   zfoo = 1filer   __pycache__)rR   rQ   printrC   rV   insertrU   curdir	importlibinvalidate_caches
__import__rH   rI   r   forgetrK   r   rS   r`   )r-   mod_filenamerX   mods       r   test_forgetzTestSupport.test_forgetm   sb   ~,g666 	%!)!$$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%29%%%#%%%		,V$$CMM&#+... (((VS[111\***]+++++ \***]++++s   ;??A7D2 27E)c                 n    t          j        t          j        df          }|                                 d S )Nr   )socketcreate_serverr   HOSTcloser-   ss     r   	test_HOSTzTestSupport.test_HOST~   s+     -"4a!899						r   c                     t          j                    }t          j        t           j        |f          }|                                 d S rA   )r   find_unused_portrx   ry   rz   r{   )r-   portr}   s      r   test_find_unused_portz!TestSupport.test_find_unused_port   s9    -// -"4d!;<<						r   c                     t          j                     }t          j        |           |                                 |                                 d S rA   )rx   r   	bind_portlistenr{   r|   s     r   test_bind_portzTestSupport.test_bind_port   s<    MOO"""	


						r   c                    t          j                    }t          j                            |          }	 t          j                            |d          }|                     t          j                            |                     t          j	        |          5 }| 
                    ||           |                     t          j                            |                     ddd           n# 1 swxY w Y   |                     t          j                            |                     t          j        |           dS # t          j        |           w xY w)z8Test that temp_dir() creates and destroys its directory.tempN)tempfilemkdtemprU   rV   realpathr^   rT   isdirr   temp_dirr,   
assertTruer`   )r-   
parent_dirrV   	temp_paths       r   test_temp_dirzTestSupport.test_temp_dir   sL   %''
W%%j11
	)7<<
F33DRW]]400111#D)) 5Y  D111d 3 34445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 RW]]400111Z(((((IZ((((s1   A&E A	C/#E /C33E 6C375E Ec                 $   t          j                    5 }|                     t          j                            |                     ddd           n# 1 swxY w Y   |                     t          j                            |                     dS )zTest passing no path.N)r   r   r   rU   rV   r   rT   )r-   r   s     r   test_temp_dir__path_nonez$TestSupport.test_temp_dir__path_none   s    !! 	6YOOBGMM)44555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6y1122222s   3AAAc                    d }t          j                    }t          j                            |          }	 |                     t          j                            |                     |                     t          ||           |                     t          j                            |                     t          j
        |           dS # t          j
        |           w xY w)z-Test passing a directory that already exists.c                 d    t          j        |           5 }t          d          # 1 swxY w Y   d S Nzshould not get here)r   r   	Exception)rV   r   s     r   call_temp_dirzMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dir   s[    #D)) 7Y 56667 7 7 7 7 7 7 7 7 7   %))N)r   r   rU   rV   r   r   r   r5   FileExistsErrorshutilr`   )r-   r   rV   s      r   *test_temp_dir__existing_dir__quiet_defaultz6TestSupport.test_temp_dir__existing_dir__quiet_default   s    	7 	7 	7 !!w%%	 OOBGMM$//000o}dCCCOOBGMM$//000M$FM$s   B C C#c                    t          j                    }t          j                            |          }	 t          j                    5 }t          j        |d          5 }| 	                    ||           ddd           n# 1 swxY w Y   d |j
        D             }ddd           n# 1 swxY w Y   |                     t          j                            |                     t          j        |           n# t          j        |           w xY w| 	                    t          |          d|           |d         }|                     |                    d|d          |           dS )	z=Test passing a directory that already exists with quiet=True.TquietNc                 6    g | ]}t          |j                  S r    r!   r$   s     r   r'   zGTestSupport.test_temp_dir__existing_dir__quiet_true.<locals>.<listcomp>        FFFqC	NNFFFr      r   z5tests may fail, unable to create temporary directory : )r   r   rU   rV   r   r   check_warningsr   r   r,   r   r   r   r   r`   r   
startswith)r-   rV   recorderr   r   r*   s         r   'test_temp_dir__existing_dir__quiet_truez3TestSupport.test_temp_dir__existing_dir__quiet_true   s   !!w%%	  /11 GX'D999 6Y$$T95556 6 6 6 6 6 6 6 6 6 6 6 6 6 6FFH4EFFFG G G G G G G G G G G G G G G
 OOBGMM$//000M$FM$X8444{ )J?C)J )J )J K K	 	 	 	 	sS   C; B)B5B)B	B)B		B)C; )B--C; 0B-15C; ;Dc                 T    t          j        dt          j        d                     dS )z?Test that a forked child process does not remove the directory.-ca  
            import os
            from test import support
            from test.support import os_helper
            with os_helper.temp_cwd() as temp_path:
                pid = os.fork()
                if pid != 0:
                    # parent process

                    # wait for the child to terminate
                    support.wait_process(pid, exitcode=0)

                    # Make sure that temp_path is still present. When the child
                    # process leaves the 'temp_cwd'-context, the __exit__()-
                    # method of the context must not remove the temporary
                    # directory.
                    if not os.path.isdir(temp_path):
                        raise AssertionError("Child removed temp_path.")
        N)r   assert_python_oktextwrapdedentr8   s    r   test_temp_dir__forked_childz'TestSupport.test_temp_dir__forked_child   s8    
 	&tX_ > . . 	 	 	 	 	r   c                    t          j                    }t          j                    5 }t          j        |          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   |                     t          j                    |           d S rA   )rU   getcwdr   r   
change_cwdr,   )r-   original_cwdr   new_cwds       r   test_change_cwdzTestSupport.test_change_cwd   s'   y{{!! 	7Y%i00 7G  )444  g6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7
 	l33333s4   B>B:BB
	
BB
	BB!$B!c                 N   t          j                    }d }t          j                    5 }t           j                            |d          }|                     t          ||           ddd           n# 1 swxY w Y   |                     t          j                    |           dS )z&Test passing a non-existent directory.c                 d    t          j        |           5 }t          d          # 1 swxY w Y   d S r   )r   r   r   )rV   r   s     r   call_change_cwdzFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwd   s[    %d++ 7w 56667 7 7 7 7 7 7 7 7 7r   does_not_existN)	rU   r   r   r   rV   r^   r5   FileNotFoundErrorr,   )r-   r   r   r   non_existent_dirs        r   !test_change_cwd__non_existent_dirz-TestSupport.test_change_cwd__non_existent_dir   s    y{{	7 	7 	7 !! 	0Z!w||J8HII/.0 0 0	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0
 	l33333s   =A33A7:A7c                    t          j                    }t          j                    5 }t           j                            |d          }t          j                    5 }t          j        |d          5 }| 	                    ||           | 	                    t          j                    |           ddd           n# 1 swxY w Y   d |j
        D             }ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   | 	                    t          |          d|           |d         }|                     |                    d|d	          |           dS )
z6Test passing a non-existent directory with quiet=True.r   Tr   Nc                 6    g | ]}t          |j                  S r    r!   r$   s     r   r'   zMTestSupport.test_change_cwd__non_existent_dir__quiet_true.<locals>.<listcomp>
  r   r   r   r   Btests may fail, unable to change the current working directory to r   )rU   r   r   r   rV   r^   r   r   r   r,   r   r   r   r   )r-   r   r   bad_dirr   r   r   r*   s           r   -test_change_cwd__non_existent_dir__quiet_truez9TestSupport.test_change_cwd__non_existent_dir__quiet_true   s-   y{{!! 	GZgll:/?@@G /11 GX)'>>> ;'$$Wl;;;$$RY[[':::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; GFH4EFFF	G G G G G G G G G G G G G G G	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	X8444{ )<.5)< )< )< = = 	 	 	 	 	sY   4C;C$2>B<0C$<C  C$C C$C;$C(	(C;+C(	,C;;C?C?c                    t           dz   }t          j                    5 }t          j        |d          5  	 ddd           n# 1 swxY w Y   d |j        D             }ddd           n# 1 swxY w Y   |                     t          |          d|           |d         }|                     |	                    d|d	          |           dS )
z0Check the warning message when os.chdir() fails._does_not_existT)rV   r   Nc                 6    g | ]}t          |j                  S r    r!   r$   s     r   r'   z>TestSupport.test_change_cwd__chdir_warning.<locals>.<listcomp>  s     BBB1AIBBBr   r   r   r   r   )
rR   r   r   r   r   r   r,   r   r   r   )r-   rV   r   r/   msgs        r   test_change_cwd__chdir_warningz*TestSupport.test_change_cwd__chdir_warning  sw   ))+-- 	C%4t<<<                BB0ABBBH	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C
 	X8444qk (8-1(8 (8 (8 9 9 	 	 	 	 	s3   A+AA+A	A+
A	A++A/2A/c                    t          j                    }t          j        t                    5  |                     t           j                            t          j                              t                     d d d            n# 1 swxY w Y   |                     t           j        	                    t                               |                     t          j                    |           d S )Nname)
rU   r   r   temp_cwdrR   r,   rV   basenamerT   rW   )r-   heres     r   test_temp_cwdzTestSupport.test_temp_cwd&  s    y{{V,,, 	D 	DRW--bikk::FCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D//000d+++++s   A
BBBc                    t          j                    }t          j        d          5 }|                     ||           |                     t           j                            |                     |                     t          j                    |           ddd           n# 1 swxY w Y   |                     t          j                    |           dS )z Test passing None to temp_cwd().Nr   )	rU   r   r   r   assertNotEqualr   rV   r   r,   )r-   r   r   s      r   test_temp_cwd__name_nonez$TestSupport.test_temp_cwd__name_none.  s    y{{T*** 	3g666OOBGMM'22333RY[['222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	l33333s   A0B%%B),B)c                 ^    |                      t          j        dddd          d           d S )N   r   r   )r   r   r   z{1: 1, 2: 2, 3: 3})r,   r   sortdictr8   s    r   test_sortdictzTestSupport.test_sortdict7  s2    )Q!q//::<PQQQQQr   c                    t          j                    }|                     t                    5 }t	          j        |d           d d d            n# 1 swxY w Y   |                     |j        j        t          j	                   d S )Ns   foo)
r   make_bad_fdr5   OSErrorrU   writer,   	exceptionerrnoEBADF)r-   fdcms      r   test_make_bad_fdzTestSupport.test_make_bad_fd:  s    "$$w'' 	!2HR   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!+U[99999s   AAAc                     t          j        | ddd           |                     t                    5  t          j        | d           d d d            d S # 1 swxY w Y   d S )Nz	def classr      )linenooffsetzx=1)r   check_syntax_errorr5   AssertionErrorr8   s    r   test_check_syntax_errorz#TestSupport.test_check_syntax_error@  s    "4QqIIII~.. 	4 	4&tU333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   AAAc                     dd l }t          j        d          5   |j        d           d d d            d S # 1 swxY w Y   d S )Nr   pprint)rp   r   CleanImportr4   )r-   rp   s     r   test_CleanImportzTestSupport.test_CleanImportE  s    &x00 	. 	.#I#H---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   7;;c                 `   t          j        dd          5  |                     dt          j                   |                     dt          j                   d d d            n# 1 swxY w Y   |                     dt          j                   |                     dt          j                   d S )Nr3   bar)r   DirsOnSysPathrH   rC   rV   rK   r8   s    r   test_DirsOnSysPathzTestSupport.test_DirsOnSysPathJ  s    (66 	+ 	+MM%***MM%***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	))))))))s   AA##A'*A'c                     t          j                    5 }t          d           d d d            n# 1 swxY w Y   |                     |                                d           d S )Nhellohello
)r   captured_stdoutrm   r,   getvalue)r-   rD   s     r   test_captured_stdoutz TestSupport.test_captured_stdoutQ  s    $&& 	&'NNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	**I66666s   044c                     t          j                    5 }t          dt          j                   d d d            n# 1 swxY w Y   |                     |                                d           d S )Nr   rj   r   )r   captured_stderrrm   rC   stderrr,   r   )r-   r   s     r   test_captured_stderrz TestSupport.test_captured_stderrV  s    $&& 	,&'
++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,**I66666s   <A A c                     t          j                    5 }|                    d           |                    d           t	                      }d d d            n# 1 swxY w Y   |                     |d           d S )Nr   r   r   )r   captured_stdinr   seekinputr,   )r-   stdincaptureds      r   test_captured_stdinzTestSupport.test_captured_stdin[  s    #%% 	KK	"""JJqMMMwwH		 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 	7+++++s   9AA Ac                 ,    t          j                     d S rA   )r   
gc_collectr8   s    r   test_gc_collectzTestSupport.test_gc_collectc  s    r   c                 ^    |                      t          j                    t                     d S rA   )assertIsInstancer   python_is_optimizedboolr8   s    r   test_python_is_optimizedz$TestSupport.test_python_is_optimizedf  s'    g9;;TBBBBBr   c                     G d d          } |            }d|_         t          j        |dd          5 }|                     |j         d           |                     |d           d d d            n# 1 swxY w Y   |                     |j         d           t          j        |dd          5 }|                     |j        d           |                     |           d d d            n# 1 swxY w Y   |                     t          |d                     t          j        |dd          5  |`d d d            n# 1 swxY w Y   |                     t          |d                     d S )Nc                       e Zd ZdS )'TestSupport.test_swap_attr.<locals>.ObjN)__name__
__module____qualname__r    r   r   Objr  j  s        Dr   r  r   xr   y)r  r   ra   r,   r  assertIsNonerT   hasattr)r-   r  objr  r  s        r   test_swap_attrzTestSupport.test_swap_attri  s1   	 	 	 	 	 	 	 	ceesC++ 	#qSUA&&&Q"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	"""sC++ 	!qSUA&&&a   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	c**+++sC++ 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	c**+++++s5   2A33A7:A7/1C,,C03C00D??EEc                 ~   ddi}t          j        |dd          5 }|                     |d         d           |                     |d           d d d            n# 1 swxY w Y   |                     |d         d           t          j        |dd          5 }|                     |d         d           |                     |           d d d            n# 1 swxY w Y   |                     d|           t          j        |dd          5  |d= d d d            n# 1 swxY w Y   |                     d|           d S )Nr  r   r   r  )r   	swap_itemr,   r  rK   )r-   Dr  r  s       r   test_swap_itemzTestSupport.test_swap_itemz  s   Gq#q)) 	#QQsVQ'''Q"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	3###q#q)) 	!QQsVQ'''a   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	a   q#q)) 	 	#	 	 	 	 	 	 	 	 	 	 	 	 	 	 	a     s5   3AA!A2CCCDD #D c                       e Zd ZdZdZdZdZdS )TestSupport.RefClassN)r  r	  r
  
attribute1
attribute2_hidden_attribute1__magic_1__r    r   r   RefClassr    s#        

!r   r  c                       e Zd ZdZdZdZdZdS )TestSupport.OtherClassN)r  r	  r
  r  
attribute3r  __magic_2__r    r   r   
OtherClassr    s"        

r   r!  c                     t          j        | j        | j                  }|                     dh|           t          j        | j        | j                  }|                     ddh|           d S )Nr  r  r   )r   detect_api_mismatchr  r!  r,   )r-   missing_itemss     r   test_detect_api_mismatchz$TestSupport.test_detect_api_mismatch  su    3DM48OE E,7773DO48MC C,6FFFFFr   c                    g d}t          j        | j        | j        |          }|                     t                      |           t          j        | j        | j        |          }|                     t                      |           d S )N)r  r  r   not_in_either)ignore)r   r#  r  r!  r,   set)r-   r(  r$  s      r    test_detect_api_mismatch__ignorez,TestSupport.test_detect_api_mismatch__ignore  s    MMM3tv? ? ?...3v? ? ?.....r   c                     dh}dh}t          j        | t          ||           h d}h d}t          j        | t          d||           |                     t
          t           j        | t                     d S )Ntempdirtemplate)extranot_exported>   	makeSuitefindTestCasesTextTestResultinstallHandlergetTestCaseNames>   
load_testsTestProgramBaseTestSuite)zunittest.resultzunittest.casezunittest.suitezunittest.loaderzunittest.mainzunittest.runnerzunittest.signalszunittest.async_case)r   check__all__r   r6   r5   r   )r-   r.  r/  s      r   test_check__all__zTestSupport.test_check__all__  s    "|T%#(*6	8 	8 	8 	8

 
 
 FEET%I $)*6	8 	8 	8 	8 	.'*>hOOOOOr   waitpidWNOHANGz need os.waitpid() and os.WNOHANGc                 r   t          j                     t          j                    }|dk    rt          j        d           t          j                    }t          j                    t           j        z   }t           j        }	 dt           _        t          j
                    }	 t          j                    |k    r|                     d           t          j        t           j        d|          5  t          j                     d d d            n# 1 swxY w Y   t           j        rnt          j        d           d|z  }|                     ||                                           |                     t           j                   |t           _        n# |t           _        w xY wt          j                     d S )Nr   FTtimeoutorig_stderrg?z2Warning -- reap_children() reaped child process %s)r   reap_childrenrU   fork_exittime	monotonicSHORT_TIMEOUTenvironment_alteredioStringIOfailra   print_warningsleeprH   r   r   )r-   pidt0deadlinewas_alteredr   r   s          r   test_reap_childrenzTestSupport.test_reap_children  s   
 	 gii!88HQKKK^>##g&;;1	6*/G'[]]F">##h..IIi(((&w'<mVTT , ,)+++, , , , , , , , , , , , , , ,
 .  
5!!!" GLCMM#v00111OOG7888*5G''+G'5555 	s2   A,F -DF DF DA1F F!Nc                    d| d| d}t           j        g|d|}d t          j                                        D             }t          j        |t
          j        t
          j        d|          }||}| 	                    |j
                                        t          |                     | 	                    |j        d           d S )	Nzfrom test.support import z; print(repr(z()))r   c                 D    i | ]\  }}|                     d           ||S )PYTHON)r   )r%   keyvalues      r   
<dictcomp>z-TestSupport.check_options.<locals>.<dictcomp>  s>     0 0 0jc5nnX..0sE 0 0 0r   T)rD   r   universal_newlinesenvr   )rC   
executablerU   environitems
subprocessrunPIPEDEVNULLr,   rD   rstriprepr
returncode)r-   argsfuncexpectedcodecmdrW  procs           r   check_optionszTestSupport.check_options  s    H4HHdHHH~11d1D10 0BJ,<,<,>,> 0 0 0~c%/_%/%715"%	' ' '
 H++--tH~~>>>!,,,,,r   c                 (   g dgdgdgdgdgdgdgdgd	gd
gdgdgddgg dddgddgddgddgddgfD ]F}|                      |          5  |                     |d           d d d            n# 1 swxY w Y   G|                     g ddd	g           d S )Nz-B-sz-S-Ez-vz-b-Pz-q-Iz-bbz-vvv-Wignore-Xdev)rn  ro  rp  faulthandler
importtimeshowrefcounttracemallocztracemalloc=3optsargs_from_interpreter_flags)rm  rk  rj  rl  subTestrh  r-   rv  s     r    test_args_from_interpreter_flagsz,TestSupport.test_args_from_interpreter_flags  sW    FFFFFFFFFGHL5M%%%>"< >"=!?#3
 	H 	HD6 4(( H H""4)FGGGH H H H H H H H H H H H H H H 	3338 6	# 	# 	# 	# 	#s   	A,,A0	3A0	c                     g dgdgdgfD ]F}|                      |          5  |                     |d           d d d            n# 1 swxY w Y   Gd S )Nz-Oz-OOz-OOOOru  !optim_args_from_interpreter_flagsrx  rz  s     r   &test_optim_args_from_interpreter_flagsz2TestSupport.test_optim_args_from_interpreter_flags%  s     FGI
 	N 	ND 4(( N N""4)LMMMN N N N N N N N N N N N N N N	N 	Ns   AA		A		c                 X    G d d          } |d          } |d          }t          j        t           dd           5  t          j        g            |                     t          j        |                     |                     t          j        |                     t          j        d d            |                     t          j        |                     |                     t          j        |                     t          j        |                                gd            |                     t          j        |                     |                     t          j        |                     t          j        dgd            |                     t          j        |                     |                     t          j        |                     t          j        dgd            |                     t          j        |                     |                     t          j        |                     t          j        dgd            |                     t          j        |                     t          j        d	gd            |                     t          j        |                     t          j        d
gd            |                     t          j        |                     |                     t          j        |                     t          j        |                                |                                gd            |                     t          j        |                     |                     t          j        |                     t          j        ddgd            |                     t          j        |                     |                     t          j        |                     d d d            n# 1 swxY w Y   t          j        t           dd           5  t          j        g            |                     t          j        |                     |                     t          j        |                     t          j        d d            |                     t          j        |                     |                     t          j        |                     t          j        d |                                g           |                     t          j        |                     |                     t          j        |                     t          j        d dg           |                     t          j        |                     |                     t          j        |                     t          j        d dg           |                     t          j        |                     |                     t          j        |                     t          j        d dg           |                     t          j        |                     t          j        d d	g           |                     t          j        |                     t          j        d d
g           |                     t          j        |                     |                     t          j        |                     t          j        d |                                |                                g           |                     t          j        |                     |                     t          j        |                     t          j        d ddg           |                     t          j        |                     |                     t          j        |                     d d d            d S # 1 swxY w Y   d S )Nc                       e Zd Zd Zd ZdS ))TestSupport.test_match_test.<locals>.Testc                     || _         d S rA   test_id)r-   r  s     r   __init__z2TestSupport.test_match_test.<locals>.Test.__init__3  s    &r   c                     | j         S rA   r  r8   s    r   idz,TestSupport.test_match_test.<locals>.Test.id6  s
    |#r   N)r  r	  r
  r  r  r    r   r   Testr  2  s2        ' ' '$ $ $ $ $r   r  z"test.test_os.FileTests.test_accessz'test.test_os.Win32ErrorTests.test_chdir_match_test_functest_osztest_*	filetests	FileTestsz*test_os.*.test_*test_access	DONTMATCH)ignore_patterns)r   ra   set_match_testsr   
match_testr  rT   )r-   r  r  
test_chdirs       r   test_match_testzTestSupport.test_match_test1  si   	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ d?@@TCDD
 w(:DAA ,	= ,	=#B'''OOG.{;;<<<OOG.z::;;; #D$///OOG.{;;<<<OOG.z::;;; #[^^%5%5$6===OOG.{;;<<<W/
;;<<< #YK666OOG.{;;<<<OOG.z::;;; #XJ555OOG.{;;<<<OOG.z::;;; #[M4888W/<<===#[M4888OOG.{;;<<< #%8$94@@@OOG.{;;<<<OOG.z::;;; #[^^%5%5z}}$GNNNOOG.{;;<<<OOG.z::;;;#]K$@$GGGOOG.{;;<<<W/
;;<<<Y,	= ,	= ,	= ,	= ,	= ,	= ,	= ,	= ,	= ,	= ,	= ,	= ,	= ,	= ,	=^ w(:DAA ,	< ,	<#B7777OOG.{;;<<<OOG.z::;;; #D$///OOG.{;;<<<OOG.z::;;; #D;>>+;+;*<===W/<<===OOG.z::;;; #D9+666W/<<===W/
;;<<< #D8*555W/<<===W/
;;<<< #D;-888OOG.{;;<<<#D;-888W/<<=== #D+>*?@@@W/<<===W/
;;<<< #D;>>+;+;Z]]__*MNNNW/<<===W/
;;<<<#D=+*FGGGW/<<===OOG.z::;;;Y,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	< ,	<s%   OPP"PO``#&`#zUnstable in EmscriptenzUnavailable on WASIc                 *   t          j                    }t          j        t          t          j                  }	 t          j                    }t          j        |           n# t          j        |           w xY w|                     ||z
  d           d S )Nr   )r   fd_countrU   rQ   __file__O_RDONLYr{   r,   )r-   startr   mores       r   test_fd_countzTestSupport.test_fd_count  sy     "$$WXr{++	%''DHRLLLLBHRLLLLq)))))s   A! !A7c                    t          j                    }t          j        t          j        d|          5  t          j        |           d d d            n# 1 swxY w Y   |                     |                                |           d S )Nr>  )rF  rG  r   ra   rI  r,   r   )r-   r   rd  r   s       r   check_print_warningzTestSupport.check_print_warning  s    w4mVLL 	' 	'!#&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'**H55555s   AAAc                 ^    |                      dd           |                      dd           d S )Nr   zWarning -- msg
za
bzWarning -- a
Warning -- b
)r  r8   s    r   test_print_warningzTestSupport.test_print_warning  sK      !3	5 	5 	5  !?	A 	A 	A 	A 	Ar   c                     t           j        st          j        dk    r!|                     t           j                   d S |                     t           j                   d S )Nwin32)r   is_emscriptenrC   platformrT   has_strftime_extensionsr   r8   s    r   test_has_strftime_extensionsz(TestSupport.test_has_strftime_extensions  sQ      	=CLG$;$;W<=====OOG;<<<<<r   rA   )Cr  r	  r
  classmethodr   r   r0   r9   r<   r>   r6   skiprE   rL   rY   rh   rv   r   requires_working_socketr~   r   r   r   r   r   r   requires_forkr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r!  r%  r*  r9  
skipUnlessr  rU   rO  requires_subprocessrh  r{  r~  r  skipIfr  is_wasir  r  r  r  r    r   r   r
   r
      s       < < [< < < [<5 5 5> > >
4 4 4Q Q Q
 X]&''D D ('D/ / /! ! !2 2 20, , ," %W$&&  '& %W$&&  '&
 %W$&&  '&) ) )3 3 3        * W  44 4 44 4 4  *  ", , ,4 4 4R R R: : :4 4 4
. . .
* * *7 7 7
7 7 7
, , ,  C C C, , ,"! ! !              G G G	/ 	/ 	/P P P6 XY//JGGB	4J4J;= =W)  )  = =) V !W ""- - - #"-"# "# "#H
N 
N 
Ng< g< g<R X_W*,DEEX_W_&;<<* * =< FE*6 6 6A A A= = = = =r   r
   __main__)r   rp   rF  rU   r   rx   rc   r[  rC   r   r   rB  r6   r   testr   test.supportr   r   r   r   r   rR   TestCaser
   r  mainr    r   r   <module>r     sY        				 				        



            & & & & & & " " " " " " & & & & & & & & & & & & ( ( ( ( ( (		`
= `
= `
= `
= `
=(# `
= `
= `
=t zHMOOOOO r   