
    chm                         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                    dBd3            Z8 ej9        d4          d5             Z:d6 Z; e
j<        ej=        d7           e
j<        ej>        d8          d9                         Z?d: Z@d; ZAd< ZBd= ZCd> ZDd? ZEd@ ZFdA ZGd2S )CTestSupportc                     t          t          j                  }t          j        dd          | _        t          j        t          d          | _        t          t          j                  |dz   k    sJ d S )Nztest.support.warnings_helperz.*used in test_support.*)likez!.*You should NOT be seeing this.*   )lenwarningsfiltersr   ignore_deprecations_from_warnings_helper_token__name___test_support_tokenclsorig_filter_lens     #  /home/conda/feedstock_root/build_artifacts/python-split_1761172146731/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.11/test/test_support.py
setUpClasszTestSupport.setUpClass   s}    h.//%,%E*1K&
 &
 &
" #*"B>#
 #
 #
 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 )Nr3   )r   import_fresh_moduler9   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_attributer4   )r-   r   get_attributer?   r6   r7   r8   r9   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stdoutr9   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)rH   assertInrD   modulesr   unloadassertNotIn)r.   rH   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   rS   rV   rW   joinmkdirrmtreerU   rX   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'   rO   rP   zfoo = 1filer   __pycache__)rS   rR   printrD   rW   insertrV   curdir	importlibinvalidate_caches
__import__rI   rJ   r   forgetrL   r   rT   ra   )r.   mod_filenamerY   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 rB   )r   find_unused_portry   rz   r{   r|   )r.   portr~   s      r   test_find_unused_portz!TestSupport.test_find_unused_port   s9    -// -"4d!;<<						r   c                     t          j                     }t          j        |           |                                 |                                 d S rB   )ry   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mkdtemprV   rW   realpathr_   rU   isdirr   temp_dirr-   
assertTruera   )r.   
parent_dirrW   	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   rV   rW   r   rU   )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)rW   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   rV   rW   r   r   r   r6   FileExistsErrorshutilra   )r.   r   rW   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   rV   rW   r   r   check_warningsr   r   r-   r   r   r   r   ra   r   
startswith)r.   rW   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dedentr9   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 rB   )rV   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   )rW   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)	rV   r   r   r   rW   r_   r6   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   )rV   r   r   r   rW   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)rW   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   )
rS   r   r   r   r   r   r-   r   r   r   )r.   rW   r   r0   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)
rV   r   r   temp_cwdrS   r-   rW   basenamerU   rX   )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   )	rV   r   r   r   assertNotEqualr   rW   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   sortdictr9   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_fdr6   OSErrorrV   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_errorr6   AssertionErrorr9   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)rq   r   CleanImportr5   )r.   rq   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 )Nr4   bar)r   DirsOnSysPathrI   rD   rW   rL   r9   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_stdoutrn   r-   getvalue)r.   rE   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   rk   r   )r   captured_stderrrn   rD   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 rB   )r   
gc_collectr9   s    r   test_gc_collectzTestSupport.test_gc_collectc  s    r   c                 ^    |                      t          j                    t                     d S rB   )assertIsInstancer   python_is_optimizedboolr9   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)r   
__module____qualname__r!   r   r   Objr  j  s        Dr   r  r   xr   y)r  r   rb   r-   r  assertIsNonerU   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  rL   )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   r7   r6   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                    t          j                     t          j                    }|dk    rt          j        d           t           j        }	 dt           _        t          j                    }t          j        t           j	                  D ][}t          j
        t           j        d|          5  t          j                     d d d            n# 1 swxY w Y   t           j        r n\d|z  }|                     ||                                           |                     t           j                   |t           _        n# |t           _        w xY wt          j                     d S )Nr   Forig_stderrz2Warning -- reap_children() reaped child process %s)r   reap_childrenrV   fork_exitenvironment_alteredioStringIOsleeping_retrySHORT_TIMEOUTrb   print_warningrI   r   r   )r.   pidwas_alteredr   _r   s         r   test_reap_childrenzTestSupport.test_reap_children  s|   
 	 gii!88HQKKK1	6*/G'[]]F+G,ABB  &w'<mVTT , ,)+++, , , , , , , , , , , , , , ,
 . E GLCMM#v00111OOG7888*5G''+G'5555 	s2   AE  -CE  C	E  C	AE   E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)rE   r   universal_newlinesenvr   )rD   
executablerV   environitems
subprocessrunPIPEDEVNULLr-   rE   rstriprepr
returncode)r.   argsfuncexpectedcodecmdrR  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   cpuc                 (   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)rj  rk  rl  faulthandler
importtimeshowrefcounttracemallocztracemalloc=3optsargs_from_interpreter_flags)ri  rg  rf  rh  subTestrc  r.   rr  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-OOOOrq  !optim_args_from_interpreter_flagsrt  rv  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		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_countrV   rR   __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=  )rB  rC  r   rb   rF  r-   r   )r.   r   r_  r   s       r   check_print_warningzTestSupport.check_print_warning9  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  r9   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_emscriptenrD   platformrU   has_strftime_extensionsr   r9   s    r   test_has_strftime_extensionsz(TestSupport.test_has_strftime_extensionsE  sQ      	=CLG$;$;W<=====OOG;<<<<<r   c                 X    t          j        d          }t          j        d|           d S )Na  
            from test import support
            import sys
            try:
                from _testcapi import USE_STACKCHECK
            except ImportError:
                USE_STACKCHECK = False

            def check(cond):
                if not cond:
                    raise AssertionError("test failed")

            # depth 1
            check(support.get_recursion_depth() == 1)

            # depth 2
            def test_func():
                check(support.get_recursion_depth() == 2)
            test_func()

            def test_recursive(depth, limit):
                if depth >= limit:
                    # cannot call get_recursion_depth() at this depth,
                    # it can raise RecursionError
                    return
                get_depth = support.get_recursion_depth()
                print(f"test_recursive: {depth}/{limit}: "
                      f"get_recursion_depth() says {get_depth}")
                check(get_depth == depth)
                test_recursive(depth + 1, limit)

            if USE_STACKCHECK:
                # f-string consumes 2 frames and -1 for USE_STACKCHECK
                IGNORE = 3
            else:
                # f-string consumes 2 frames
                IGNORE = 2

            # depth up to 25
            with support.infinite_recursion(max_depth=25):
                limit = sys.getrecursionlimit()
                print(f"test with sys.getrecursionlimit()={limit}")
                test_recursive(2, limit - IGNORE)

            # depth up to 500
            with support.infinite_recursion(max_depth=500):
                limit = sys.getrecursionlimit()
                print(f"test with sys.getrecursionlimit()={limit}")
                test_recursive(2, limit - IGNORE)
        r   )r   r   r   r   )r.   r`  s     r   test_get_recursion_depthz$TestSupport.test_get_recursion_depthK  s4     1  1 1d 	&tT22222r   c                    fddD ]}t          j        |          5  t          j                    } |           	  |dz              |                     d           n# t          $ r Y nw xY wd d d            n# 1 swxY w Y   t          j        d          5  	  d           |                     d           n# t          $ r Y nw xY wd d d            d S # 1 swxY w Y   d S )Nc                 ,    | r | dz
             d S d S r|  r!   )depthrecursive_functions    r   r  z6TestSupport.test_recursion.<locals>.recursive_function  s0     .""519-----. .r   )r         r   zRecursionError was not raised   )r   infinite_recursionget_recursion_availablefailRecursionError)r.   	max_depth	availabler  s      @r   test_recursionzTestSupport.test_recursion  s   	. 	. 	. 	. 	. & 	? 	?I+I66 ? ?#;==	 #"9---
?&&y1}555 II=>>>> &   D? ? ? ? ? ? ? ? ? ? ? ? ? ? ?" '** 	; 	;;""1%%% 		9:::: "   	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;sj   A?A#A?#
A0-A?/A00A??B	B	C!C,C
CCCCC#&C#c                    t           j        }d}|dz  }|dz  }|dz  }|                      |d          d           |                      |d          d|z             |                      |d          t          d|z                       |                      |d          t          d	|z                       |                      |d
          |           dD ]m}|                     |          5  |                     t                    5   ||           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   nd S )Ni   0kr   3kr   z2.4mg333333@4gr  1t) 3z3.5.10k10x)limit)r   _parse_memlimitr-   intru  r6   
ValueError)r.   parseKiBMiBGiBTiBr  s          r   test_parse_memlimitzTestSupport.test_parse_memlimit  s   'DjDjDjta(((ta#g...vC#I777tc!c'll333tc***0 	! 	!EE** ! !&&z22 ! !E%LLL! ! ! ! ! ! ! ! ! ! ! ! ! ! !! ! ! ! ! ! ! ! ! ! ! ! ! ! !	! 	!s6   6E D)E )D--E 0D-1E  E	E	c                    d}d}t           j        }t           j        }	 t          j        dk    rt          j        d           |                     t           j        |           |                     t           j        |           ddz  |z  }t          j        | d           |                     t           j        t          j                   |                     t           j        ||z             n^t          j        d           |                     t           j        t          j                   |                     t           j        |           |t           _        |t           _        d S # |t           _        |t           _        w xY w)Nl        l        r  r   d   t)r   
max_memusereal_max_memuserD   maxsizeset_memlimitr-   )r.   _4GiBr  old_max_memuseold_real_max_memusebigs         r   test_set_memlimitzTestSupport.test_set_memlimit  sK    +%5	:{U""$T***  !3U;;;  !8%@@@fm$YYY///  !3S[AAA  !8#)DDDD$T***  !3S[AAA  !8%@@@!/G&9G### "0G&9G#9999s   D/E' 'Fc                    t          j        d          }|st          j        d          }t          j                            |          }t          j                            |          s|                     d|           t          j                            |d          }t          j                            |          s|                     d|d           ddh}t          j        |          }| 	                    t          j        ||          |dhz             t          j                            |d	          }| 	                    t          j        |t          j        |                    |dd
hz             t          j                            |d          }| 	                    t          j        |t          j        |                    |           d S )N
abs_srcdirsrcdirz,cannot access Python source code directory: Modulesz landmark is missingz.gitrm   buildDocvenvObjects)	sysconfigget_config_varrV   rW   abspathrX   skipTestr_   listdirr-   r   copy_python_src_ignore)r.   src_dirlandmarkignorednamesrW   s         r   test_copy_python_src_ignorez'TestSupport.test_copy_python_src_ignore  s   *<88 	9.x88G'//'** w~~g&& 	+MM *%* * + + + 7<<33w~~h'' 	@MM ?&? ? ? @ @ @ =)
7##7GG G9,	. 	. 	. w||GU++7bj>N>NOO GV#44	6 	6 	6 w||GY//7bj>N>NOO 	" 	" 	" 	" 	"r   rB   )Hr   r	  r
  classmethodr   r   r1   r:   r=   r?   r7   skiprF   rM   rZ   ri   rw   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  rV   rJ  requires_subprocessrc  requires_resourcerw  rz  skipIfr  is_wasir  r  r  r  r  r  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      = =  D !W ""- - - #"- Wu%%"# "# &%"#H
N 
N 
N X_W*,DEEX_W_&;<<* * =< FE*6 6 6A A A= = =43 43 43l; ; ;@! ! !": : :."" "" "" "" ""r   r
   __main__)r   rq   rB  rV   r   ry   rd   rV  rD   r  r   r   r7   r   testr   test.supportr   r   r   r   r   rS   TestCaser
   r   mainr!   r   r   <module>r     s\        				 				        



               & & & & & & " " " " " " & & & & & & & & & & & & ( ( ( ( ( (		Q" Q" Q" Q" Q"(# Q" Q" Q"R zHMOOOOO r   