
    7bh5l                     ,   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j4                          yy)    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j4                         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
jf                   e4e5d.      xr	  e4e5d/      d0       ej4                         d1               Z6 ejn                         dBd3       Z8 ejr                  d4      d5        Z:d6 Z; e
jx                  ejz                  d7       e
jx                  ej|                  d8      d9               Z?d: Z@d; ZAd< ZBd= ZCd> ZDd? ZEd@ ZFdA ZGy2)CTestSupportc                     t        t        j                        }t        j                  dd      | _        t        j                  t        d      | _        y )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     ;/opt/python-3.12.12/usr/lib/python3.12/test/test_support.py
setUpClasszTestSupport.setUpClass   sF    h../%,%E%E*1K&
" #*"B"B>#
    c                     t        t        j                        }t        j                  | j
                  | j                         y N)r   r   r   r   clear_ignored_deprecationsr   r   r   s     r   tearDownClasszTestSupport.tearDownClass&   s2    h../**&&##	
r   c                 >   	 t        j                  d      5 }t        j                          t        j                  dt
               |D cg c]  }t        |j                         }}d d d        | j                  t              d|       y c c}w # 1 sw Y   +xY w)NT)recordzYou should NOT be seeing this.r   )
r   catch_warningsr   _warn_about_deprecationwarnDeprecationWarningstrmessageassertEqualr   )selfwarning_objswmessagess       r   $test_ignored_deprecations_are_silentz0TestSupport.test_ignored_deprecations_are_silent/   sx    G$$D1\335MM:<NO0<=1AIIH= 2 	X84 > 21s   3BB'BBBc                     t        j                  d       | j                  t        j                  t         j                  d       y )Nftplibfoo)r   import_moduleassertRaisesunittestSkipTestr'   s    r   test_import_modulezTestSupport.test_import_module7   s1    ##H-(++'55u	>r   c                 .    t        j                  d       y )Nr-   )r   import_fresh_moduler3   s    r   test_import_fresh_modulez$TestSupport.test_import_fresh_module<   s    ))(3r   c                     | j                  t        j                  | d      | j                         | j	                  t
        j                  t        j                  | d       y )Ntest_get_attributer.   )r&   r   get_attributer9   r0   r1   r2   r3   s    r   r9   zTestSupport.test_get_attribute?   sI    ..t5IJ//	1(++W-B-BD%Pr   zfailing buildbotsc                 h    | j                  t        j                         t        j                         y r   )r&   r   get_original_stdoutsysstdoutr3   s    r   test_get_original_stdoutz$TestSupport.test_get_original_stdoutD   s    446

Cr   c                     dd l }| j                  dt        j                         t	        j
                  d       | j                  dt        j                         y )Nr   sched)rA   assertInr=   modulesr   unloadassertNotIn)r'   rA   s     r   test_unloadzTestSupport.test_unloadH   s9    gs{{+W%#++.r   c                    t        t        dd      5 }	 d d d        t        j                  t               | j	                  t
        j                  j                  t                     t        j                  t               y # 1 sw Y   nxY w)Nr)   utf-8encoding)openTESTFNr   unlinkassertFalseospathexists)r'   fs     r   test_unlinkzTestSupport.test_unlinkN   sX    &#0A 1 /0 	 10s   BBc                    t         j                  dz   }t        j                  j	                  |d      }t        j
                  |       t        j
                  |       t        j                  |       | j                  t        j                  j                  |             t        j                  t        dd      5  t        j                  |       d d d        t        j
                  |       t        j
                  |       t        j                  |t        j                  t        j                  z         t        j                  t        dd      5  t        j                  |       d d d        | j                  t        j                  j                  |             t        j
                  |       t        j
                  |       t        j                  |d       t        j                  t        dd      5  t        j                  |       d d d        | j                  t        j                  j                  |             y # 1 sw Y   xxY w# 1 sw Y   xY w# 1 sw Y   QxY w)Ndsubdirverboser   )r   rL   rO   rP   joinmkdirrmtreerN   rQ   r   	swap_attrchmodstatS_IRUSRS_IXUSR)r'   dirpath
subdirpaths      r   test_rmtreezTestSupport.test_rmtreeU   s   ""S(WW\\'84


!01w	15W% 6 	

$,,t||34w	15W% 601


!w	15W% 601 65 65 65s$   <II;I!II!I*c                    t         dz   }t        |dd      5 }t        d|       d d d        t        j                  j                  dt        j                         t        j                          	 t        t               }| j                  t         t        j                         t        j                  t                | j                  t         t        j                         t        j                  d= t!        j"                  |       t!        j$                  d       y # 1 sw Y   xY w# t        j                  d= t!        j"                  |       t!        j$                  d       w xY w)	Nz.pyr)   rH   rI   zfoo = 1filer   __pycache__)rL   rK   printr=   rP   insertrO   curdir	importlibinvalidate_caches
__import__rB   rC   r   forgetrE   r   rM   rZ   )r'   mod_filenamerR   mods       r   test_forgetzTestSupport.test_forgetm   s    ~,g6!)!$ 7299%##%		,V$CMM&#++.  (VS[[1\*]+ 76 \*]+s   D1A0D) D&)=E&c                 n    t        j                  t        j                  df      }|j	                          y )Nr   )socketcreate_serverr   HOSTcloser'   ss     r   	test_HOSTzTestSupport.test_HOST~   s&      -"4"4a!89		r   c                     t        j                         }t        j                  t         j                  |f      }|j                          y r   )r   find_unused_portrr   rs   rt   ru   )r'   portrw   s      r   test_find_unused_portz!TestSupport.test_find_unused_port   s4    --/  -"4"4d!;<		r   c                     t        j                          }t        j                  |       |j                          |j	                          y r   )rr   r   	bind_portlistenru   rv   s     r   test_bind_portzTestSupport.test_bind_port   s-    MMO"	
		r   c                    	 t        j                         }t        j                  j	                  |      }	 t        j                  j                  |d      }| j                  t        j                  j                  |             t        j                  |      5 }| j                  ||       | j                  t        j                  j                  |             d d d        | j                  t        j                  j                  |             t        j                  |       y # 1 sw Y   MxY w# t        j                  |       w xY w)Ntemp)tempfilemkdtemprO   rP   realpathrX   rN   isdirr   temp_dirr&   
assertTruerZ   )r'   
parent_dirrP   	temp_paths       r   test_temp_dirzTestSupport.test_temp_dir   s    F%%'
WW%%j1
	)77<<
F3DRWW]]401##D)Y  D1d 34 * RWW]]401Z( *)
 Z(s%   A#D2 AD&6D2 &D/+D2 2E	c                    	 t        j                         5 }| j                  t        j                  j                  |             d d d        | j                  t        j                  j                               y # 1 sw Y   8xY wr   )r   r   r   rO   rP   r   rN   )r'   r   s     r   test_temp_dir__path_nonez$TestSupport.test_temp_dir__path_none   sU    #!YOOBGGMM)45 "y12 "!s   /A<<Bc                    	 d }t        j                         }t        j                  j	                  |      }	 | j                  t        j                  j                  |             | j                  t        ||       | j                  t        j                  j                  |             t        j                  |       y # t        j                  |       w xY w)Nc                 \    t        j                  |       5 }t        d      # 1 sw Y   y xY wNzshould not get here)r   r   	Exception)rP   r   s     r   call_temp_dirzMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dir   s'    ##D)Y 566 *)   "+)r   r   rO   rP   r   r   r   r0   FileExistsErrorshutilrZ   )r'   r   rP   s      r   *test_temp_dir__existing_dir__quiet_defaultz6TestSupport.test_temp_dir__existing_dir__quiet_default   s    ;	7 !ww%	 OOBGGMM$/0o}dCOOBGGMM$/0MM$FMM$s   A3C Cc                    	 t        j                         }t        j                  j	                  |      }	 t        j                         5 }t        j                  |d      5 }| j                  ||       d d d        |j                  D cg c]  }t        |j                         }}d d d        | j                  t        j                  j                  |             t        j                   |       | j                  t#              d|       |d   }| j                  |j%                  d|d      |       y # 1 sw Y   xY wc c}w # 1 sw Y   xY w# t        j                   |       w xY w)NTquiet   r   z5tests may fail, unable to create temporary directory : )r   r   rO   rP   r   r   check_warningsr   r   r&   r   r$   r%   r   r   r   rZ   r   
startswith)r'   rP   recorderr   r)   r   r"   s          r   'test_temp_dir__existing_dir__quiet_truez3TestSupport.test_temp_dir__existing_dir__quiet_true   s    K!ww%	  //1X''D9Y$$T95 :4<4E4EF4EqC		N4EF 2
 OOBGGMM$/0MM$X84{ +??Chb)J K	 :9F 21 MM$sG   E 
E"D;5EE'E)6E ;E	 EEE E/c                 X    	 t        j                  dt        j                  d             y )N-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.")
        )r   assert_python_oktextwrapdedentr3   s    r   test_temp_dir__forked_childz'TestSupport.test_temp_dir__forked_child   s'    M 	&&tX__ > . 	r   c                    t        j                         }t        j                         5 }t        j                  |      5 }| j                  ||       | j                  t        j                         |       d d d        d d d        | j                  t        j                         |       y # 1 sw Y   6xY w# 1 sw Y   :xY wr   )rO   getcwdr   r   
change_cwdr&   )r'   original_cwdr   new_cwds       r   test_change_cwdzTestSupport.test_change_cwd   s    yy{!Y%%i0G  )4  g6 1 "
 	l3	 10 "!s"   B77B+6B7+B4	0B77C c                 <   	 t        j                         }d }t        j                         5 }t         j                  j                  |d      }| j                  t        ||       d d d        | j                  t        j                         |       y # 1 sw Y   .xY w)Nc                 \    t        j                  |       5 }t        d      # 1 sw Y   y xY wr   )r   r   r   )rP   r   s     r   call_change_cwdzFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwd   s'    %%d+w 566 ,+r   does_not_exist)	rO   r   r   r   rP   rX   r0   FileNotFoundErrorr&   )r'   r   r   r   non_existent_dirs        r   !test_change_cwd__non_existent_dirz-TestSupport.test_change_cwd__non_existent_dir   sw    4yy{	7 !Z!ww||J8HI/.0 "
 	l3 "!s   8BBc                    	 t        j                         }t        j                         5 }t         j                  j                  |d      }t        j                         5 }t        j                  |d      5 }| j                  ||       | j                  t        j                         |       d d d        |j                  D cg c]  }t        |j                         }}d d d        d d d        | j                  t              d|       |d   }| j                  |j                  dd      |       y # 1 sw Y   xY wc c}w # 1 sw Y   ixY w# 1 sw Y   mxY w)Nr   Tr   r   r   Btests may fail, unable to change the current working directory to r   )rO   r   r   r   rP   rX   r   r   r   r&   r   r$   r%   r   r   r   )	r'   r   r   bad_dirr   r   r)   r   r"   s	            r   -test_change_cwd__non_existent_dir__quiet_truez9TestSupport.test_change_cwd__non_existent_dir__quiet_true   s   Dyy{!Zggll:/?@G //1X))'>'$$Wl;$$RYY[': ? 5=4E4EF4EqC		N4EF	 2 " 	X84{ +..5[)< = 	 ?> G	 21 "!sG   5EE
77D9.E
E E
"E9E>E

E	EEc                    	 t         dz   }t        j                         5 }t        j                  |d      5  	 d d d        |j
                  D cg c]  }t        |j                         }}d d d        | j                  t              d|       |d   }| j                  |j                  d|d      |       y # 1 sw Y   xY wc c}w # 1 sw Y   axY w)N_does_not_existT)rP   r   r   r   r   r   )rL   r   r   r   r   r   r$   r%   r&   r   r   r   )r'   rP   r   r)   r*   msgs         r   test_change_cwd__chdir_warningz*TestSupport.test_change_cwd__chdir_warning  s    >))++-%%4t< =080A0AB0A1AII0AHB .
 	X84qk *--1HB(8 9 	 =<B .-s-   CB<CC+C<C	CCc                    t        j                         }t        j                  t              5  | j                  t         j                  j                  t        j                               t               d d d        | j                  t         j                  j                  t                     | j                  t        j                         |       y # 1 sw Y   `xY wN)name)
rO   r   r   temp_cwdrL   r&   rP   basenamerN   rQ   )r'   heres     r   test_temp_cwdzTestSupport.test_temp_cwd&  s    yy{V,RWW--biik:FC -/0d+ -,s   ACCc                    	 t        j                         }t        j                  d       5 }| j	                  ||       | j                  t         j                  j                  |             | j                  t        j                         |       d d d        | j                  t        j                         |       y # 1 sw Y   .xY wr   )	rO   r   r   r   assertNotEqualr   rP   r   r&   )r'   r   r   s      r   test_temp_cwd__name_nonez$TestSupport.test_temp_cwd__name_none.  s    .yy{T*g6OOBGGMM'23RYY['2 + 	l3	 +*s   A%B>>Cc                 V    | j                  t        j                  dddd      d       y )N      r   )r   r   r   z{1: 1, 2: 2, 3: 3})r&   r   sortdictr3   s    r   test_sortdictzTestSupport.test_sortdict7  s$    ))Q!q/:<PQr   c                    t        j                         }| j                  t              5 }t	        j
                  |d       d d d        | j                  j                  j                  t        j                         y # 1 sw Y   >xY w)Ns   foo)
r   make_bad_fdr0   OSErrorrO   writer&   	exceptionerrnoEBADF)r'   fdcms      r   test_make_bad_fdzTestSupport.test_make_bad_fd:  sZ    ""$w'2HHR  (++U[[9 ('s   A>>Bc                     t        j                  | ddd       | j                  t              5  t        j                  | d       d d d        y # 1 sw Y   y xY w)Nz	def classr      )linenooffsetzx=1)r   check_syntax_errorr0   AssertionErrorr3   s    r   test_check_syntax_errorz#TestSupport.test_check_syntax_error@  s@    ""4QqI~.&&tU3 /..s   AAc                     dd l }t        j                  d      5   |j                  d       d d d        y # 1 sw Y   y xY w)Nr   pprint)rj   r   CleanImportr/   )r'   rj   s     r   test_CleanImportzTestSupport.test_CleanImportE  s/    &&x0#I##H- 100s   6?c                 Z   t        j                  dd      5  | j                  dt        j                         | j                  dt        j                         d d d        | j                  dt        j                         | j                  dt        j                         y # 1 sw Y   JxY w)Nr.   bar)r   DirsOnSysPathrB   r=   rP   rE   r3   s    r   test_DirsOnSysPathzTestSupport.test_DirsOnSysPathJ  sn    ((6MM%*MM%* 7 	))	 76s   AB!!B*c                     t        j                         5 }t        d       d d d        | j                  j	                         d       y # 1 sw Y   *xY w)Nhellohello
)r   captured_stdoutrg   r&   getvalue)r'   r>   s     r   test_captured_stdoutz TestSupport.test_captured_stdoutQ  s<    $$&&'N '*I6 '&s   A

Ac                     t        j                         5 }t        dt        j                         d d d        | j                  j                         d       y # 1 sw Y   *xY w)Nr   rd   r   )r   captured_stderrrg   r=   stderrr&   r   )r'   r   s     r   test_captured_stderrz TestSupport.test_captured_stderrV  sC    $$&&'

+ '*I6 '&s   AA#c                     t        j                         5 }|j                  d       |j                  d       t	               }d d d        | j                  d       y # 1 sw Y   xY w)Nr   r   r   )r   captured_stdinr   seekinputr&   )r'   stdincaptureds      r   test_captured_stdinzTestSupport.test_captured_stdin[  sN    ##%KK	"JJqMwH	 &
 	7+ &%s   -AA&c                 ,    t        j                          y r   )r   
gc_collectr3   s    r   test_gc_collectzTestSupport.test_gc_collectc  s    r   c                 T    | j                  t        j                         t               y r   )assertIsInstancer   python_is_optimizedboolr3   s    r   test_python_is_optimizedz$TestSupport.test_python_is_optimizedf  s    g99;TBr   c                     G d d      } |       }d|_         t        j                  |dd      5 }| j                  |j                   d       | j                  |d       d d d        | j                  |j                   d       t        j                  |dd      5 }| j                  |j                  d       | j                  |       d d d        | j                  t        |d             t        j                  |dd      5  |`d d d        | j                  t        |d             y # 1 sw Y   xY w# 1 sw Y   nxY w# 1 sw Y   =xY w)Nc                       e Zd Zy)'TestSupport.test_swap_attr.<locals>.ObjN)r   
__module____qualname__ r   r   Objr   j  s    r   r  r   xr   y)r  r   r[   r&   r  assertIsNonerN   hasattr)r'   r  objr  r  s        r   test_swap_attrzTestSupport.test_swap_attri  s   	 	esC+qSUUA&Q" , 	"sC+qSUUA&a  , 	c*+sC+ ,c*+ ,+ ,+ ,+s#   /D).D5E)D25D>E
c                 &   ddi}t        j                  |dd      5 }| j                  |d   d       | j                  |d       d d d        | j                  |d   d       t        j                  |dd      5 }| j                  |d   d       | j                  |       d d d        | j	                  d|       t        j                  |dd      5  |d= d d d        | j	                  d|       y # 1 sw Y   xY w# 1 sw Y   ]xY w# 1 sw Y   4xY w)Nr  r   r   r  )r   	swap_itemr&   r  rE   )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  *) *) *)s#   (C/8'C;D/C8;DDc                       e Zd ZdZdZdZdZy)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y)TestSupport.OtherClassN)r   r   r   r  
attribute3r  __magic_2__r  r   r   
OtherClassr    s    

r   r  c                     t        j                  | j                  | j                        }| j	                  dh|       t        j                  | j                  | j                        }| j	                  ddh|       y )Nr  r  r  )r   detect_api_mismatchr  r  r&   )r'   missing_itemss     r   test_detect_api_mismatchz$TestSupport.test_detect_api_mismatch  se    33DMM48OOE,733DOO48MMC,6Fr   c                 $   g d}t        j                  | j                  | j                  |      }| j	                  t               |       t        j                  | j                  | j                  |      }| j	                  t               |       y )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  si    M33tv?.33v?.r   c                     dh}dh}t        j                  | t        ||       h d}h d}t        j                  | t        d||       | j	                  t
        t         j                  | t               y )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   r1   r0   r   )r'   r%  r&  s      r   test_check__all__zTestSupport.test_check__all__  su    "|T%#(*6	8

 FT%I $)*6	8 	.'*>*>h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 ]V  }t        j                  t         j                  d|      5  t        j                          d d d        t         j
                  sV n d|z  }| j                  ||j                                | j                  t         j
                         |t         _        t        j                          y # 1 sw Y   xY w# |t         _        w xY w)Nr   Forig_stderrz2Warning -- reap_children() reaped child process %s)r   reap_childrenrO   fork_exitenvironment_alteredioStringIOsleeping_retrySHORT_TIMEOUTr[   print_warningrB   r   r   )r'   pidwas_alteredr   _r   s         r   test_reap_childrenzTestSupport.test_reap_children  s   
 	 ggi!8HHQK11	6*/G'[[]F++G,A,AB&&w'<'<mVT))+ U
 .. C GLCMM#v01OOG778*5G' 	! UT +6G's,   A*E >EE ,AE E	E E,Nc                    d| d| d}t         j                  g|d|}t        j                  j	                         D ci c]  \  }}|j                  d      s|| }}}t        j                  |t        j                  t        j                  d|      }	||}| j                  |	j                  j                         t        |             | j                  |	j                  d       y c c}}w )	Nzfrom test.support import z; print(repr(z()))r   PYTHONT)r>   r   universal_newlinesenvr   )r=   
executablerO   environitemsr   
subprocessrunPIPEDEVNULLr&   r>   rstriprepr
returncode)
r'   argsfuncexpectedcodecmdkeyvaluerE  procs
             r   check_optionszTestSupport.check_options  s    *4&dV4H~~11d1D1,.JJ,<,<,> 0,>jc5nnX. Ez,> 0~~c%/__%/%7%715"%	'
 H++-tH~>!,0s   C-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 ]/  }| j                  |      5  | j                  |d       d d d        1 | j                  g ddd	g       y # 1 sw Y   RxY w)Nz-B-sz-S-Ez-vz-b-Pz-q-Iz-bbz-vvv-Wignore-Xdev)r_  r`  ra  faulthandler
importtimeshowrefcounttracemallocztracemalloc=3optsargs_from_interpreter_flags)r^  r\  r[  r]  subTestrX  r'   rg  s     r    test_args_from_interpreter_flagsz,TestSupport.test_args_from_interpreter_flags  s    
 FFFFFFFFFGHL5M%>"< >"=!?#3
D6 4(""4)FG )(7
< 	38 6	# )(s   A::B	c                     g dgdgdgfD ]/  }| j                  |      5  | j                  |d       d d d        1 y # 1 sw Y   <xY w)Nz-Oz-OOz-OOOOrf  !optim_args_from_interpreter_flagsri  rk  s     r   &test_optim_args_from_interpreter_flagsz2TestSupport.test_optim_args_from_interpreter_flags  sT     FGI
D 4(""4)LM )(
 )(s	   =A	zUnstable in EmscriptenzUnavailable on WASIc                 .   t        j                         }t        j                  t        t        j
                        }	 t        j                         }t        j                  |       | j                  ||z
  d       y # t        j                  |       w xY wNr   )r   fd_countrO   rK   __file__O_RDONLYru   r&   )r'   startr   mores       r   test_fd_countzTestSupport.test_fd_count)  sg     ""$WWXr{{+	%%'DHHRLq) HHRLs   A= =Bc                 
   t        j                         }t        j                  t        j                  d|      5  t        j                  |       d d d        | j                  |j                         |       y # 1 sw Y   *xY w)Nr4  )r9  r:  r   r[   r=  r&   r   )r'   r   rR  r   s       r   check_print_warningzTestSupport.check_print_warning9  sZ    w44mVL!!#& M*H5 MLs   A99Bc                 L    | j                  dd       | j                  dd       y )Nr   zWarning -- msg
za
bzWarning -- a
Warning -- b
)ry  r3   s    r   test_print_warningzTestSupport.test_print_warning?  s)      !3	5  !?	Ar   c                     t         j                  st        j                  dk(  r | j	                  t         j
                         y | j                  t         j
                         y )Nwin32)r   is_emscriptenr=   platformrN   has_strftime_extensionsr   r3   s    r   test_has_strftime_extensionsz(TestSupport.test_has_strftime_extensionsE  s<      CLLG$;W<<=OOG;;<r   c                 Z    t        j                  d      }t        j                  d|       y )Nap  
            from test import support
            import sys

            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)

            # 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)

            # 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)
        r   )r   r   r   r   )r'   rS  s     r   test_get_recursion_depthz$TestSupport.test_get_recursion_depthK  s(     &  &N 	&&tT2r   c                    fddD ]Y  }t        j                  |      5  t        j                         } |       	  |dz          | j                  d       d d d        [ t        j                  d      5  	  d       | j                  d       d d d        y # t        $ r Y Nw xY w# 1 sw Y   xY w# t        $ r Y /w xY w# 1 sw Y   y xY w)Nc                 "    | r | dz
         y y rq  r  )depthrecursive_functions    r   r  z6TestSupport.test_recursion.<locals>.recursive_functionx  s    "519- r   )r         r   zRecursionError was not raisedr   )r   infinite_recursionget_recursion_availablefailRecursionError)r'   	max_depth	availabler  s      @r   test_recursionzTestSupport.test_recursionv  s    	. &I++I6#;;=	 #9-
?&y1}5 II=> 76 &$ ''*;"1% 		9: +* &  76( "  +*s^   B-B
B-:C<B9C	B*'B-)B**B--B6	9	CCCCCc                 ,   t         j                  }d}|dz  }|dz  }|dz  }| j                   |d      d       | j                   |d      d|z         | j                   |d      t        d|z               | j                   |d      t        d	|z               | j                   |d
      |       dD ]C  }| j	                  |      5  | j                  t              5   ||       d d d        d d d        E y # 1 sw Y   xY w# 1 sw Y   \xY w)Ni   0kr   3kr   z2.4mg333333@4g   1t) 3z3.5.10k10x)limit)r   _parse_memlimitr&   intrj  r0   
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tc!c'l3tc*0EE*&&z2%L 3 +* 122 +*s$   D
"	C>+D
>DD

D	c                 *   d}d}t         j                  }t         j                  }	 t        j                  dkD  rt        j
                  d       | j                  t         j                  |       | j                  t         j                  |       ddz  |z  }t        j
                  | d       | j                  t         j                  t        j                         | j                  t         j                  ||z         nct        j
                  d       | j                  t         j                  t        j                         | j                  t         j                  |       |t         _        |t         _        y # |t         _        |t         _        w xY w)Nl        l        r  r   d   t)r   
max_memusereal_max_memuser=   maxsizeset_memlimitr&   )r'   _4GiBr  old_max_memuseold_real_max_memusebigs         r   test_set_memlimitzTestSupport.test_set_memlimit  s%    ++%55	:{{U"$$T*  !3!3U;  !8!8%@fm$$uAY/  !3!3S[[A  !8!8#)D$$T*  !3!3S[[A  !8!8%@!/G&9G# "0G&9G#s   D=E: :Fc                    t        j                  d      }|st        j                  d      }t        j                  j	                  |      }t        j                  j                  |      s| j                  d|       t        j                  j                  |d      }t        j                  j                  |      s| j                  d|d       ddh}t        j                  |      }| j                  t        j                  ||      |dhz         t        j                  j                  |d	      }| j                  t        j                  |t        j                  |            |dd
hz         t        j                  j                  |d      }| j                  t        j                  |t        j                  |            |       y )N
abs_srcdirsrcdirz,cannot access Python source code directory: Modulesz landmark is missingz.gitrf   buildDocvenvObjects)	sysconfigget_config_varrO   rP   abspathrQ   skipTestrX   listdirr&   r   copy_python_src_ignore)r'   src_dirlandmarkignorednamesrP   s         r   test_copy_python_src_ignorez'TestSupport.test_copy_python_src_ignore  sr   **<8..x8G''//'* ww~~g&MM %[* + 77<<3ww~~h'MM &\)=? @ =)

7#77G G9,	. ww||GU+77bjj>NO GV#44	6 ww||GY/77bjj>NO 	"r   r   )Hr   r   r   classmethodr   r   r+   r4   r7   r9   r1   skipr?   rF   rS   rb   rp   r   requires_working_socketrx   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!  r0  
skipUnlessr  rO   rA  requires_subprocessrX  requires_resourcerl  ro  skipIfr~  is_wasirw  ry  r{  r  r  r  r  r  r  r  r   r   r
   r
      s   < < < <5>
4Q
 X]]&'D (D/!20," %W$$& ' %W$$& '
 %W$$& ')3  * W 444*",4R:4
.
*7
7
,C,"!  G	/P6 XY/JGB	4J;=W   =  D !W  "- #- Wu%"# &"#H
N X__W**,DEX__W__&;<* = F*6A=)3V;@!":.""r   r
   __main__)r   rj   r9  rO   r   rr   r]   rI  r=   r  r   r   r1   r   testr   test.supportr   r   r   r   r   rL   TestCaser
   r   mainr  r   r   <module>r     s{      	 	     
       & " & & (			F"(## F"| zHMMO r   