hg ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZddlmZddlmZddlmZddlmZddlmZejZGdd e jZed kre jdSdS) N)support) import_helper) os_helper) script_helper) socket_helper)warnings_helperc|eZdZedZedZdZdZdZdZ e j ddZ d Z d Zd Zd Zejd ZejdZejdZdZdZdZdZejdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&d Z'd!Z(d"Z)d#Z*d$Z+d%Z,d&Z-Gd'd(Z.Gd)d*Z/d+Z0d,Z1d-Z2e j3e4e5d.o e4e5d/d0ejd1Z6ej7d=d3Z8d4Z9d5Z:d6Z;e j<ej=d7e j<ej>d8d9Z?d:Z@d;ZAd<ZBd2S)> TestSupportcttj}tjdd|_tjdd|_ttj|dzksJdS)Nztest.support.warnings_helperz.*used in test_support.*)likeztest.test_supportz!.*You should NOT be seeing this.*)lenwarningsfiltersrignore_deprecations_from_warnings_helper_token_test_support_tokenclsorig_filter_lens (/usr/lib/python3.11/test/test_support.py setUpClasszTestSupport.setUpClasss}h.//%,%E *1K& & & "#*"B &I# # # 8#$$!(;;;;;;;cttj}tj|j|jttj|dz ksJdS)Nr )rrrrclear_ignored_deprecationsrrrs r tearDownClasszTestSupport.tearDownClass&s\h.//*  &  #   8#$$!(;;;;;;;rctjd5}tjtjdt d|D}dddn #1swxYwY|t|d|dS)z9Test support.ignore_deprecations_from() silences warningsT)recordzYou should NOT be seeing this.c6g|]}t|jSstrmessage.0ws r zDTestSupport.test_ignored_deprecations_are_silent..4s ===1AI===rNr)rcatch_warningsr_warn_about_deprecationwarnDeprecationWarning assertEqualr)self warning_objsmessagess r$test_ignored_deprecations_are_silentz0TestSupport.test_ignored_deprecations_are_silent/s  $D 1 1 1 >\  3 5 5 5 M: > > > > > > > > > > > > > > X844444s:AA #A ctjd|tjtjddS)Nftplibfoo)r import_module assertRaisesunittestSkipTestr-s rtest_import_modulezTestSupport.test_import_module7sB#H--- (+'5u > > > > >rc.tjddS)Nr2)rimport_fresh_moduler8s rtest_import_fresh_modulez$TestSupport.test_import_fresh_module<s)(33333rc|tj|d|j|t jtj|ddS)Ntest_get_attributer3)r,r get_attributer>r5r6r7r8s rr>zTestSupport.test_get_attribute?sV .t5IJJ/ 1 1 1 (+W-BD%PPPPPrzfailing buildbotsch|tjtjdSN)r,rget_original_stdoutsysstdoutr8s rtest_get_original_stdoutz$TestSupport.test_get_original_stdoutDs) 466 CCCCCrcddl}|dtjt jd|dtjdS)Nrsched)rGassertInrCmodulesrunload assertNotIn)r-rGs r test_unloadzTestSupport.test_unloadHsP  gs{+++W%%% #+.....rc8ttdd5} dddn #1swxYwYtjt|t jttjtdS)Nr&utf-8encoding)openTESTFNrunlink assertFalseospathexists)r-fs r test_unlinkzTestSupport.test_unlinkNs &# 0 0 0 A                    //000     s &**ctjdz}tj|d}tj|tj|tj||tj|tj tdd5tj|dddn #1swxYwYtj|tj|tj |tj tjztj tdd5tj|dddn #1swxYwY|tj|tj|tj|tj |dtj tdd5tj|dddn #1swxYwY|tj|dS)Ndsubdirverboser)rrRrUrVjoinmkdirrmtreerTrWr swap_attrchmodstatS_IRUSRS_IXUSR)r-dirpath subdirpaths r test_rmtreezTestSupport.test_rmtreeUs"S(W\\'844   !!! 00111  w 1 5 5 & &  W % % % & & & & & & & & & & & & & & &   $,t|3444  w 1 5 5 & &  W % % % & & & & & & & & & & & & & & & 00111   !  w 1 5 5 & &  W % % % & & & & & & & & & & & & & & & 0011111s69CC!CE55E9<E9 H++H/2H/ctdz}t|dd5}td|dddn #1swxYwYtjdt jtj  tt}| ttj tjt|ttj tjd=t!j|t!jddS#tjd=t!j|t!jdwxYw) Nz.pyr&rNrOzfoo = 1filer __pycache__)rRrQprintrCrVinsertrUcurdir importlibinvalidate_caches __import__rHrIrforgetrKrrSr`)r- mod_filenamerXmods r test_forgetzTestSupport.test_forgetmsb~ ,g 6 6 6 %! )! $ $ $ $ % % % % % % % % % % % % % % % 29%%%#%%% ,V$$C MM&#+ . . .   ( ( (   VS[ 1 1 1  \ * * *  ] + + + + +  \ * * *  ] + + + +s;??A7D227E)cntjtjdf}|dS)Nr)socket create_serverrHOSTcloser-ss r test_HOSTzTestSupport.test_HOST~s+  -"4a!8 9 9  rctj}tjtj|f}|dSrA)rfind_unused_portrxryrzr{)r-portr}s rtest_find_unused_portz!TestSupport.test_find_unused_ports9-//  -"4d!; < <  rctj}tj|||dSrA)rxr bind_portlistenr{r|s rtest_bind_portzTestSupport.test_bind_ports< MOO"""    rctj}tj|} tj|d}|tj|tj |5}| ||| tj|dddn #1swxYwY|tj|tj |dS#tj |wxYw)z8Test that temp_dir() creates and destroys its directory.tempN) tempfilemkdtemprUrVrealpathr^rTisdirrtemp_dirr, assertTruer`)r- parent_dirrV temp_paths r test_temp_dirzTestSupport.test_temp_dirsL%'' W%%j11  )7<< F33D   RW]]400 1 1 1#D)) 5Y  D111 d 3 3444 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5   RW]]400 1 1 1  Z ( ( ( ( (I Z ( ( ( (s1A&EA C/# E/C33E6C375EEc$tj5}|tj|dddn #1swxYwY|tj|dS)zTest passing no path.N)rrrrUrVrrT)r-rs rtest_temp_dir__path_nonez$TestSupport.test_temp_dir__path_nones   ! ! 6Y OOBGMM)44 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 y1122222s3AAAcd}tj}tj|} |tj||t|||tj|tj |dS#tj |wxYw)z-Test passing a directory that already exists.cdtj|5}td#1swxYwYdSNzshould not get here)rr Exception)rVrs r call_temp_dirzMTestSupport.test_temp_dir__existing_dir__quiet_default..call_temp_dirs[#D)) 7Y 5666 7 7 7 7 7 7 7 7 7 7 %))N) rrrUrVrrrr5FileExistsErrorshutilr`)r-rrVs r*test_temp_dir__existing_dir__quiet_defaultz6TestSupport.test_temp_dir__existing_dir__quiet_defaults 7 7 7!!w%% OOBGMM$// 0 0 0   o}d C C C OOBGMM$// 0 0 0 M$     FM$    s BC C#ctj}tj|} t j5}tj|d5}| ||dddn #1swxYwYd|j D}dddn #1swxYwY| tj |tj|n#tj|wxYw| t|d||d}| |d|d|dS) z=Test passing a directory that already exists with quiet=True.TquietNc6g|]}t|jSr r!r$s rr'zGTestSupport.test_temp_dir__existing_dir__quiet_true.. FFFqC NNFFFrrz5tests may fail, unable to create temporary directory : )rrrUrVrrcheck_warningsrrr,rrrrr`r startswith)r-rVrecorderrrr*s r'test_temp_dir__existing_dir__quiet_truez3TestSupport.test_temp_dir__existing_dir__quiet_trues!!w%%  /11 GX'D9996Y$$T9555666666666666666FFH4EFFF G G G G G G G G G G G G G G G OOBGMM$// 0 0 0 M$    FM$     X8444{ )J?C)J)J)JKK     sSC;B)B5 B)B B)B B) C;)B--C;0B-15C;;DcTtjdtjddS)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)rassert_python_oktextwrapdedentr8s rtest_temp_dir__forked_childz'TestSupport.test_temp_dir__forked_childs8 &tX_> . .      rctj}tj5}tj|5}||||tj|dddn #1swxYwYdddn #1swxYwY|tj|dSrA)rUgetcwdrr change_cwdr,)r- original_cwdrnew_cwds rtest_change_cwdzTestSupport.test_change_cwds'y{{   ! ! 7Y%i00 7G  )444  g666 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 l33333s4B>B: BB B B BB!$B!cNtj}d}tj5}tj|d}|t||dddn #1swxYwY|tj|dS)z&Test passing a non-existent directory.cdtj|5}td#1swxYwYdSr)rrr)rVrs rcall_change_cwdzFTestSupport.test_change_cwd__non_existent_dir..call_change_cwds[%d++ 7w 5666 7 7 7 7 7 7 7 7 7 7rdoes_not_existN) rUrrrrVr^r5FileNotFoundErrorr,)r-rrrnon_existent_dirs r!test_change_cwd__non_existent_dirz-TestSupport.test_change_cwd__non_existent_dirsy{{  7 7 7  ! ! 0Z!w||J8HII    /. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 l33333s=A33A7:A7ctj}tj5}tj|d}t j5}tj|d5}| ||| tj|dddn #1swxYwYd|j D}dddn #1swxYwYdddn #1swxYwY| t|d||d}| | d|d |dS) z6Test passing a non-existent directory with quiet=True.rTrNc6g|]}t|jSr r!r$s rr'zMTestSupport.test_change_cwd__non_existent_dir__quiet_true.. rrrrBtests may fail, unable to change the current working directory to r)rUrrrrVr^rrrr,rrrr)r-rrbad_dirrrrr*s r-test_change_cwd__non_existent_dir__quiet_truez9TestSupport.test_change_cwd__non_existent_dir__quiet_trues-y{{   ! ! GZgll:/?@@G /11 GX)'>>>;'$$Wl;;;$$RY[[':::;;;;;;;;;;;;;;;GFH4EFFF  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 X8444{ )<.5)<)<)<==     sY4C;C$2>B<0 C$<C C$C C$ C;$C( (C;+C( ,C;;C?C?ctdz}tj5}tj|d5 dddn #1swxYwYd|jD}dddn #1swxYwY|t|d||d}|| d|d |dS) z0Check the warning message when os.chdir() fails._does_not_existT)rVrNc6g|]}t|jSr r!r$s rr'z>TestSupport.test_change_cwd__chdir_warning..s BBB1AIBBBrrrrr) rRrrrrrr,rrr)r-rVrr/msgs rtest_change_cwd__chdir_warningz*TestSupport.test_change_cwd__chdir_warningsw))  + - - C%4t<<<                 BB0ABBBH C C C C C C C C C C C C C C C X8444qk (8-1(8(8(899     s3A+A A+A A+ A A++A/2A/ctj}tjt5|tjtjtdddn #1swxYwY|tj t|tj|dS)Nname) rUrrtemp_cwdrRr,rVbasenamerTrW)r-heres r test_temp_cwdzTestSupport.test_temp_cwd&sy{{  V , , , D D   RW--bikk::F C C C D D D D D D D D D D D D D D D //000 d+++++sA BB Bctj}tjd5}||||tj||tj|dddn #1swxYwY|tj|dS)z Test passing None to temp_cwd().Nr) rUrrrassertNotEqualrrVrr,)r-rrs rtest_temp_cwd__name_nonez$TestSupport.test_temp_cwd__name_none.sy{{  T * * * 3g    6 6 6 OOBGMM'22 3 3 3   RY[[' 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 l33333sA0B%%B),B)c^|tjddddddS)Nr r)rr rz{1: 1, 2: 2, 3: 3})r,rsortdictr8s r test_sortdictzTestSupport.test_sortdict7s2 )Q!q//::.ObjN)__name__ __module__ __qualname__r rrObjrjs Drr rxry)r rrar,r  assertIsNonerThasattr)r-r objr r s rtest_swap_attrzTestSupport.test_swap_attris1        cee  sC + + #q   SUA & & &   Q " " " # # # # # # # # # # # # # # # """  sC + + !q   SUA & & &   a  ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! c**+++  sC + +                  c**+++++s52A33A7:A7/1C,,C03C00D??EEc~ddi}tj|dd5}||dd||ddddn #1swxYwY||ddtj|dd5}||dd||dddn #1swxYwY|d|tj|dd5|d=dddn #1swxYwY|d|dS)Nr rrr )r swap_itemr,rrK)r-Dr r s rtest_swap_itemzTestSupport.test_swap_itemzs G  q#q ) ) #Q   QsVQ ' ' '   Q " " " # # # # # # # # # # # # # # # 3###  q#q ) ) !Q   QsVQ ' ' '   a  ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! a    q#q ) )  #                a     s53AA!A2CCC DD #D ceZdZdZdZdZdZdS)TestSupport.RefClassN)rr r  attribute1 attribute2_hidden_attribute1 __magic_1__r rrRefClassrs#  ! rrceZdZdZdZdZdZdS)TestSupport.OtherClassN)rr r r attribute3r __magic_2__r rr OtherClassrs"    rr!ctj|j|j}|dh|tj|j|j}|ddh|dS)Nrrr )rdetect_api_mismatchrr!r,)r- missing_itemss rtest_detect_api_mismatchz$TestSupport.test_detect_api_mismatchsu3DM48OEE  ,7773DO48MCC  , 6 FFFFFrcgd}tj|j|j|}|t |tj|j|j|}|t |dS)N)rrr  not_in_either)ignore)rr#rr!r,set)r-r(r$s r test_detect_api_mismatch__ignorez,TestSupport.test_detect_api_mismatch__ignoresMMM3 tv???   ...3v???   .....rcdh}dh}tj|t||hd}hd}tj|td|||t tj|tdS)Ntempdirtemplate)extra not_exported> makeSuite findTestCasesTextTestResultinstallHandlergetTestCaseNames> load_tests TestProgram BaseTestSuite)zunittest.resultz unittest.casezunittest.suitezunittest.loaderz unittest.mainzunittest.runnerzunittest.signalszunittest.async_case)r check__all__rr6r5r)r-r.r/s rtest_check__all__zTestSupport.test_check__all__s "| T%#(*6 8 8 8 8    FEE T%I$)*6 8 8 8 8 .'*>hOOOOOrwaitpidWNOHANGz need os.waitpid() and os.WNOHANGcrtjtj}|dkrtjdt j}t jtjz}tj} dt_tj } t j|kr| dtj tj d|5tjdddn #1swxYwYtjrnt jdd|z}||||tj|t_n#|t_wxYwtjdS)NrFTtimeout orig_stderrg?z2Warning -- reap_children() reaped child process %s)r reap_childrenrUfork_exittime monotonic SHORT_TIMEOUTenvironment_alteredioStringIOfailra print_warningsleeprHrr)r-pidt0deadline was_alteredrrs rtest_reap_childrenzTestSupport.test_reap_childrens gii !88 HQKKK ^  >##g&;;1  6*/G '[]]F ">##h..IIi(((&w'z-TestSupport.check_options..s>000jc5nnX..0sE000rT)rDruniversal_newlinesenvr)rC executablerUenvironitems subprocessrunPIPEDEVNULLr,rDrstriprepr returncode)r-argsfuncexpectedcodecmdrWprocs r check_optionszTestSupport.check_optionssH4HHdHHH~11d1D100BJ,<,<,>,>000~c%/_%/%715"% '''  H ++--tH~~>>> !,,,,,rc(gdgdgdgdgdgdgdgdgd gd gd gd gd dggdd dgd dgd dgd dgd dgfD]F}||5||ddddn #1swxYwYG|gddd gdS)Nz-B-sz-S-Ez-vz-b-Pz-q-Iz-bbz-vvv-Wignore-Xdev)rnrorp faulthandler importtime showrefcount tracemallocz tracemalloc=3optsargs_from_interpreter_flags)rmrkrjrlsubTestrhr-rvs r test_args_from_interpreter_flagsz,TestSupport.test_args_from_interpreter_flagssW  F F F F F F F F F G H L 5M % % % > " < > " = ! ? #3  H HD64(( H H""4)FGGG H H H H H H H H H H H H H H H 3338 6 # # # # #s A,,A0 3A0 cgdgdgdgfD]F}||5||ddddn #1swxYwYGdS)Nz-Oz-OOz-OOOOru!optim_args_from_interpreter_flagsrxrzs r&test_optim_args_from_interpreter_flagsz2TestSupport.test_optim_args_from_interpreter_flags%s  F G I   N ND4(( N N""4)LMMM N N N N N N N N N N N N N N N N NsAA A cXGdd}|d}|d}tjtdd5tjg|tj||tj|tjdd|tj||tj|tj|gd|tj||tj|tjdgd|tj||tj|tjdgd|tj||tj|tjdgd|tj|tjd gd|tj|tjd gd|tj||tj|tj||gd|tj||tj|tjd d gd|tj||tj|dddn #1swxYwYtjtdd5tjg |tj||tj|tjdd|tj||tj|tjd|g|tj||tj|tjddg|tj||tj|tjddg|tj||tj|tjddg|tj|tjdd g|tj|tjdd g|tj||tj|tjd||g|tj||tj|tjdd d g|tj||tj|ddddS#1swxYwYdS)NceZdZdZdZdS))TestSupport.test_match_test..Testc||_dSrAtest_id)r-rs r__init__z2TestSupport.test_match_test..Test.__init__3s & rc|jSrArr8s ridz,TestSupport.test_match_test..Test.id6s |#rN)rr r rrr rrTestr2s2 ' ' ' $ $ $ $ $rrz"test.test_os.FileTests.test_accessz'test.test_os.Win32ErrorTests.test_chdir_match_test_functest_osztest_* filetests FileTestsz*test_os.*.test_* test_access DONTMATCH)ignore_patterns)rraset_match_testsr match_testrrT)r-rr test_chdirs rtest_match_testzTestSupport.test_match_test1si $ $ $ $ $ $ $ $d?@@ TCDD  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/ ;; < < >+;+;*< = = =   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, <, <, <, <, <, <, <, <, <, <, <, <, <, <, <, <, <, )rFrGrrarIr,r)r-rrdrs rcheck_print_warningzTestSupport.check_print_warnings  w4mV L L ' '  !# & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' **H55555sAAAc^|dd|dddS)NrzWarning -- msg za bzWarning -- a Warning -- b )rr8s rtest_print_warningzTestSupport.test_print_warningsK   !3 5 5 5   !? A A A A Arctjstjdkr!|tjdS|tjdS)Nwin32)r is_emscriptenrCplatformrThas_strftime_extensionsrr8s rtest_has_strftime_extensionsz(TestSupport.test_has_strftime_extensionssQ   =CLG$;$;   W< = = = = = OOG; < < < < r6skiprErLrYrhrvrrequires_working_socketr~rrrrrr requires_forkrrrrrrrrrrrrrrrrrrrrr!r%r*r9 skipUnlessrrUrOrequires_subprocessrhr{r~rskipIfris_wasirrrrr rrr r s<<[<<<[<555>>> 444QQQ X]&''DD('D/// !!!2220,,,"%W$&&'&%W$&&'& %W$&&'& ) ) )333    *W4444 4 4 4*   ",,,444RRR::: 444 ... ***777 777 ,,,CCC,,," ! ! !  GGG / / /PPP6XY//JGGB 4J4J;==W) ) ==) V!W "" - - -#" -"#"#"#H N N Ng<g<grsY    &&&&&&""""""&&&&&&&&&&&&((((((  ` =` =` =` =` =(#` =` =` =t zHMOOOOOr