Rh5l,ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZddlmZddlmZddlmZddlmZddlmZej,ZGdd e j.Zed k(re j4yy) N)support) import_helper) os_helper) script_helper) socket_helper)warnings_helperceZdZedZedZdZdZdZdZ e jddZ d Z d Zd Zd Zej$d Zej$dZej$dZdZdZdZdZej4dZdZdZdZdZdZ 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 jfe4e5d.xr e4e5d/d0ej4d1Z6ejndBd3Z8ejrd4d5Z:d6Z;e jxejzd7e jxej|d8d9Z?d:Z@d;ZAd<ZBd=ZCd>ZDd?ZEd@ZFdAZGy2)C TestSupportcttj}tjdd|_tjt d|_ttj|dzk(sJy)Nztest.support.warnings_helperz.*used in test_support.*)likez!.*You should NOT be seeing this.*)lenwarningsfiltersrignore_deprecations_from_warnings_helper_token__name___test_support_tokenclsorig_filter_lens (/usr/lib/python3.12/test/test_support.py setUpClasszTestSupport.setUpClasssfh../%,%E%E *1K& "#*"B"B ># 8##$!(;;;;cttj}tj|j |j ttj|dz k(sJy)Nr )rrrrclear_ignored_deprecationsrrrs r tearDownClasszTestSupport.tearDownClass&sRh../**  & &  # # 8##$!(;;;;rc<tjd5}tjtjdt |Dcgc]}t |j}}ddd|jtd|ycc}w#1swY+xYw)z9Test support.ignore_deprecations_from() silences warningsT)recordzYou should NOT be seeing this.Nr) rcatch_warningsr_warn_about_deprecationwarnDeprecationWarningstrmessage assertEqualr)self warning_objswmessagess r$test_ignored_deprecations_are_silentz0TestSupport.test_ignored_deprecations_are_silent/s{  $ $D 1 >\  3 3 5 MM: X84> > >s3B B &B BBctjd|jtjtjdy)Nftplibfoo)r import_module assertRaisesunittestSkipTestr's rtest_import_modulezTestSupport.test_import_module7s1##H- (++'55u >rc.tjdy)Nr-)rimport_fresh_moduler3s rtest_import_fresh_modulez$TestSupport.test_import_fresh_module<s))(3rc|jtj|d|j|j t j tj|dy)Ntest_get_attributer.)r&r get_attributer9r0r1r2r3s rr9zTestSupport.test_get_attribute?sI ..t5IJ// 1 (++W-B-BD%Przfailing buildbotsch|jtjtjyN)r&rget_original_stdoutsysstdoutr3s rtest_get_original_stdoutz$TestSupport.test_get_original_stdoutDs 446 Crcddl}|jdtjt j d|j dtjy)Nrsched)rBassertInr>modulesrunload assertNotIn)r'rBs r test_unloadzTestSupport.test_unloadHs9 gs{{+W% #++.rcttdd5} dddtjt|j t j jttjty#1swYnxYw)Nr)utf-8encoding)openTESTFNrunlink assertFalseospathexists)r'fs r test_unlinkzTestSupport.test_unlinkNs_ &# 0 A    /0   s BB ctjdz}tjj |d}tj |tj |tj ||jtjj|tjtdd5tj |dddtj |tj |tj|tjtjztjtdd5tj |ddd|jtjj|tj |tj |tj|dtjtdd5tj |ddd|jtjj|y#1swYxxYw#1swYxYw#1swYQxYw)Ndsubdirverboser)rrMrPrQjoinmkdirrmtreerOrRr swap_attrchmodstatS_IRUSRS_IXUSR)r'dirpath subdirpaths r test_rmtreezTestSupport.test_rmtreeUs""S(WW\\'84   ! 01   w 1 5 &   W % &   $,,t||34   w 1 5 &   W % & 01   !   w 1 5 &   W % & 01 & &  & & & &s$<II;I!II!I*ctdz}t|dd5}td|dddtjj dt jtj tt}|jttjtjt|jttjtjd=t!j"|t!j$dy#1swYxYw#tjd=t!j"|t!j$dwxYw) Nz.pyr)rIrJzfoo = 1filer __pycache__)rMrLprintr>rQinsertrPcurdir importlibinvalidate_caches __import__rCrDrforgetrFrrNr[)r' mod_filenamerSmods r test_forgetzTestSupport.test_forgetms~ ,g 6 %! )! $ % 299%##% ,V$C MM&#++ .   (   VS[[ 1   \ *   ] + % %   \ *   ] +sD1A0D)D&)=E&cntjtjdf}|j y)Nr)socket create_serverrHOSTcloser'ss r test_HOSTzTestSupport.test_HOST~s&  -"4"4a!8 9  rctj}tjtj|f}|j yr<)rfind_unused_portrsrtrurv)r'portrxs rtest_find_unused_portz!TestSupport.test_find_unused_ports4--/  -"4"4d!; <  rctj}tj||j|j yr<)rsr bind_portlistenrvrws rtest_bind_portzTestSupport.test_bind_ports- MMO"    rctj}tjj |} tjj |d}|j tjj|tj|5}|j|||jtjj|ddd|j tjj|tj|y#1swYMxYw#tj|wxYw)z8Test that temp_dir() creates and destroys its directory.tempN) tempfilemkdtemprPrQrealpathrYrOisdirrtemp_dirr& assertTruer[)r' parent_dirrQ temp_paths r test_temp_dirzTestSupport.test_temp_dirs%%' WW%%j1  )77<< F3D   RWW]]40 1##D) 5Y  D1 d 34 5   RWW]]40 1   Z (  5 5   Z (s%A#D1AD%6D1%D.*D11Ectj5}|jtjj |ddd|j tjj y#1swY8xYw)zTest passing no path.N)rrrrPrQrrO)r'rs rtest_temp_dir__path_nonez$TestSupport.test_temp_dir__path_nonesY    ! 6Y OOBGGMM)4 5 6 y12 6 6s /A;;Bcd}tj}tjj |} |j tjj ||jt|||j tjj |tj|y#tj|wxYw)z-Test passing a directory that already exists.c\tj|5}td#1swYyxYwNzshould not get here)rr Exception)rQrs r call_temp_dirzMTestSupport.test_temp_dir__existing_dir__quiet_default..call_temp_dirs.##D) 7Y 566 7 7 "+N) rrrPrQrrrr0FileExistsErrorshutilr[)r'rrQs r*test_temp_dir__existing_dir__quiet_defaultz6TestSupport.test_temp_dir__existing_dir__quiet_defaults 7!ww% OOBGGMM$/ 0   o}d C OOBGGMM$/ 0 MM$ FMM$ s A3CCctj}tjj |} t j 5}tj|d5}|j||ddd|jDcgc]}t|j}}ddd|jtjj|tj ||jt#d||d}|j|j%d|d|y#1swYxYwcc}w#1swYxYw#tj |wxYw)z=Test passing a directory that already exists with quiet=True.TquietNrz5tests may fail, unable to create temporary directory : )rrrPrQrrcheck_warningsrrr&rr$r%rrrr[r startswith)r'rQrecorderrr)rr"s r'test_temp_dir__existing_dir__quiet_truez3TestSupport.test_temp_dir__existing_dir__quiet_trues,!ww%  //1 GX''D96Y$$T9564<4E4EFqC NFF G OOBGGMM$/ 0 MM$  X84{ +??Chb)JK 66F G G MM$ sGE E !D:4E  E&E (6E:E ? E  EEE.cVtjdtjdy)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_oktextwrapdedentr3s rtest_temp_dir__forked_childz'TestSupport.test_temp_dir__forked_childs$ &&tX__> .  rctj}tj5}tj|5}|j |||j tj|dddddd|j tj|y#1swY6xYw#1swY:xYwr<)rPgetcwdrr change_cwdr&)r' original_cwdrnew_cwds rtest_change_cwdzTestSupport.test_change_cwdsyy{    ! 7Y%%i0 7G  )4  g6 7 7 l3  7 7 7 7s"B77B+6B7+B4 0B77Cc:tj}d}tj5}tjj |d}|j t||ddd|jtj|y#1swY.xYw)z&Test passing a non-existent directory.c\tj|5}td#1swYyxYwr)rrr)rQrs rcall_change_cwdzFTestSupport.test_change_cwd__non_existent_dir..call_change_cwds.%%d+ 7w 566 7 7rdoes_not_existN) rPrrrrQrYr0FileNotFoundErrorr&)r'rrrnon_existent_dirs r!test_change_cwd__non_existent_dirz-TestSupport.test_change_cwd__non_existent_dirs{yy{  7   ! 0Z!ww||J8HI    /. 0 0 l3  0 0s 8BBctj}tj5}tjj |d}t j5}tj|d5}|j|||jtj|ddd|jDcgc]}t|j}}dddddd|jtd||d}|j|jdd|y#1swYxYwcc}w#1swYixYw#1swYmxYw) z6Test passing a non-existent directory with quiet=True.rTrNrrBtests may fail, unable to change the current working directory to r)rPrrrrQrYrrrr&rr$r%rrr) r'rrbad_dirrrr)rr"s r-test_change_cwd__non_existent_dir__quiet_truez9TestSupport.test_change_cwd__non_existent_dir__quiet_trues3yy{    ! GZggll:/?@G //1 GX))'>;'$$Wl;$$RYY[':;5=4E4EFqC NFF  G G X84{ +..5[)<= ;;G  G G G GsG5EE 67D8-E EE !E8E = E  E EEctdz}tj5}tj|d5 ddd|j Dcgc]}t |j}}ddd|jtd||d}|j|jd|d|y#1swYxYwcc}w#1swYaxYw) z0Check the warning message when os.chdir() fails._does_not_existT)rQrNrrrr) rMrrrrrr$r%r&rrr)r'rQrr)r*msgs rtest_change_cwd__chdir_warningz*TestSupport.test_change_cwd__chdir_warnings))  + + - C%%4t<  080A0AB1AIIBHB C X84qk *--1HB(89    B C Cs-C B;C C*C ;C C  Cctj}tjt5|j tj jtjtddd|jtj jt|j tj|y#1swY`xYw)Nname) rPrrtemp_cwdrMr&rQbasenamerOrR)r'heres r test_temp_cwdzTestSupport.test_temp_cwd&syy{   V , D   RWW--biik:F C D /0 d+ D Ds ACCctj}tjd5}|j |||j tj j||jtj|ddd|jtj|y#1swY.xYw)z Test passing None to temp_cwd().Nr) rPrrrassertNotEqualrrQrr&)r'rrs rtest_temp_cwd__name_nonez$TestSupport.test_temp_cwd__name_none.syy{   T * 3g    6 OOBGGMM'2 3   RYY[' 2 3 l3  3 3s A%B==CcV|jtjdddddy)Nr r)rr rz{1: 1, 2: 2, 3: 3})r&rsortdictr3s r test_sortdictzTestSupport.test_sortdict7s$ ))Q!q/:xYw)Nsfoo) r make_bad_fdr0OSErrorrPwriter& exceptionerrnoEBADF)r'fdcms rtest_make_bad_fdzTestSupport.test_make_bad_fd:sa  " " $   w ' !2 HHR  ! ++U[[9 ! !s A>>Bctj|ddd|jt5tj|ddddy#1swYyxYw)Nz def classr)linenooffsetzx=1)rcheck_syntax_errorr0AssertionErrorr3s rtest_check_syntax_errorz#TestSupport.test_check_syntax_error@sI""4QqI   ~ . 4  & &tU 3 4 4 4s AAcddl}tjd5|jddddy#1swYyxYw)Nrpprint)rkr CleanImportr/)r'rks rtest_CleanImportzTestSupport.test_CleanImportEs8  & &x 0 . #I # #H - . . .s6?cZtjdd5|jdtj|jdtjddd|j dtj|j dtjy#1swYJxYw)Nr.bar)r DirsOnSysPathrCr>rQrFr3s rtest_DirsOnSysPathzTestSupport.test_DirsOnSysPathJsu  ( ( 6 + MM% * MM% * + ) )  + +s AB!!B*ctj5}tdddd|jj dy#1swY*xYw)Nhellohello )rcaptured_stdoutrhr&getvalue)r'r?s rtest_captured_stdoutz TestSupport.test_captured_stdoutQsC  $ $ & & 'N  *I6  s A  Actj5}tdtjddd|j j dy#1swY*xYw)Nrrer)rcaptured_stderrrhr>stderrr&r)r'rs rtest_captured_stderrz TestSupport.test_captured_stderrVsJ  $ $ & ,& ' + , *I6 , ,s AA#ctj5}|jd|jdt }ddd|j dy#1swYxYw)Nrrr)rcaptured_stdinrseekinputr&)r'stdincaptureds rtest_captured_stdinzTestSupport.test_captured_stdin[sU  # # %  KK " JJqMwH   7+   s -AA&c,tjyr<)r gc_collectr3s rtest_gc_collectzTestSupport.test_gc_collectcsrcT|jtjtyr<)assertIsInstancerpython_is_optimizedboolr3s rtest_python_is_optimizedz$TestSupport.test_python_is_optimizedfs g99;TBrcGdd}|}d|_tj|dd5}|j|jd|j|dddd|j|jdtj|dd5}|j|jd|j |ddd|j t|dtj|dd5|`ddd|j t|dy#1swYxYw#1swYnxYw#1swY=xYw)Nc eZdZy)'TestSupport.test_swap_attr..ObjN)r __module__ __qualname__rrObjrjs rrrxry)rrr\r&r assertIsNonerOhasattr)r'robjrrs rtest_swap_attrzTestSupport.test_swap_attris   e   sC + #q   SUUA &   Q " # "   sC + !q   SUUA &   a  ! c*+   sC +   c*+ # # ! !  s#/D).D5E)D25D>E c&ddi}tj|dd5}|j|dd|j|dddd|j|ddtj|dd5}|j|dd|j|ddd|j d|tj|dd5|d=ddd|j d|y#1swYxYw#1swY]xYw#1swY4xYw)Nrrrr)r swap_itemr&rrF)r'Drrs rtest_swap_itemzTestSupport.test_swap_itemzs  G   q#q ) #Q   QsVQ '   Q " # 3#   q#q ) !Q   QsVQ '   a  ! a   q#q ) #  a  # # ! !  s#(C/8'C;D/C8;DDceZdZdZdZdZdZy)TestSupport.RefClassN)rrr attribute1 attribute2_hidden_attribute1 __magic_1__rrrRefClassrs  ! rrceZdZdZdZdZdZy)TestSupport.OtherClassN)rrrr attribute3r __magic_2__rrr OtherClassrs    rrctj|j|j}|j dh|tj|j|j}|j ddh|y)Nrrr)rdetect_api_mismatchrrr&)r' missing_itemss rtest_detect_api_mismatchz$TestSupport.test_detect_api_mismatchse33DMM48OOE  ,733DOO48MMC  , 6 Frc$gd}tj|j|j|}|j t |tj|j|j|}|j t |y)N)rrr not_in_either)ignore)rrrrr&set)r'rrs r test_detect_api_mismatch__ignorez,TestSupport.test_detect_api_mismatch__ignoresiM33 tv?   .33v?   .rcdh}dh}tj|t||hd}hd}tj|td|||j t tj|ty)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__rr1r0r)r'r%r&s rtest_check__all__zTestSupport.test_check__all__su "| T%#(*6 8  F T%I$)*6 8 .'*>*>hOrwaitpidWNOHANGz need os.waitpid() and os.WNOHANGctjtj}|dk(rtjdtj } dt_t j}tjtjD]V}tjtjd|5tjdddtj sVnd|z}|j||j|jtj |t_tjy#1swYxYw#|t_wxYw)NrF orig_stderrz2Warning -- reap_children() reaped child process %s)r reap_childrenrPfork_exitenvironment_alteredioStringIOsleeping_retry SHORT_TIMEOUTr\ print_warningrCrr)r'pid was_alteredr_rs rtest_reap_childrenzTestSupport.test_reap_childrens ggi !8 HHQK11  6*/G '[[]F++G,A,AB &&w'<'EE,AEE E E,Ncd|d|d}tjg|d|}tjj Dcic]\}}|j ds||}}}t j|t jt jd|} ||}|j| jjt||j| jdycc}}w) Nzfrom test.support import z ; print(repr(z()))rPYTHONT)r?runiversal_newlinesenvr)r> executablerPenvironitemsr subprocessrunPIPEDEVNULLr&r?rstriprepr returncode) r'argsfuncexpectedcodecmdkeyvaluerEprocs r check_optionszTestSupport.check_optionss*4& dV4H~~11d1D1,.JJ,<,<,>0jc5nnX.Ez00~~c%/__%/%7%715"% '  H ++-tH~> !,0sC-cpuc gdgdgdgdgdgdgdgdgd gd gd gd gd dggdd dgd dgd dgd dgd dgfD]/}|j|5|j|dddd1|jgddd gy#1swYRxYw)Nz-B-sz-S-Ez-vz-b-Pz-q-Iz-bbz-vvv-Wignore-Xdev)r_r`ra faulthandler importtime showrefcount tracemallocz tracemalloc=3optsargs_from_interpreter_flags)r^r\r[r]subTestrXr'rgs r test_args_from_interpreter_flagsz,TestSupport.test_args_from_interpreter_flagss  F F F F F F F F F G H L 5M % > " < > " = ! ? #3  HD64( H""4)FG H H7 H< 38 6 # H Hs A::B cgdgdgdgfD]/}|j|5|j|dddd1y#1swYplatformrOhas_strftime_extensionsrr3s rtest_has_strftime_extensionsz(TestSupport.test_has_strftime_extensionsEs<  CLLG$;   W<< = OOG;; = 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)rrrr)r'rSs rtest_get_recursion_depthz$TestSupport.test_get_recursion_depthKs(& & N &&tT2rcfddD]Y}tj|5tj}| |dz|jdddd[tjd5 d|jddddy#t$rYNwxYw#1swYxYw#t$rY/wxYw#1swYyxYw)Nc"|r |dz yyrqr)depthrecursive_functions rrz6TestSupport.test_recursion..recursive_functionxs"519-r)rrzRecursionError was not raisedr)rinfinite_recursionget_recursion_availablefailRecursionError)r' max_depth availablers @rtest_recursionzTestSupport.test_recursionvs .& ?I++I6 ?#;;= #9- ?&y1}5II=> ? ? ?$ ' ' * ; ;"1% 9:  ; ; & ? ?("   ; ;s^B- B B-:C<B9C B*'B-)B**B--B6 9 CCCCCc,tj}d}|dz}|dz}|dz}|j|dd|j|dd|z|j|dtd|z|j|dtd |z|j|d |d D]C}|j | 5|j t 5||ddddddEy#1swYxYw#1swY\xYw) Ni0kr3krz2.4mg333333@4g1t)3z3.5.10k10x)limit)r_parse_memlimitr&intrjr0 ValueError)r'parseKiBMiBGiBTiBrs rtest_parse_memlimitzTestSupport.test_parse_memlimits''DjDjDj ta( ta#g. vC#I7 tc!c'l3 tc*0 !EE* !&&z2!%L! ! ! !!! ! !s$ D " C>+D >D D  D c*d}d}tj}tj} tjdkDrtj d|j tj||j tj|ddz|z}tj |d|j tjtj|j tj||znctj d|j tjtj|j tj||t_|t_y#|t_|t_wxYw)Nllrr dt)r max_memusereal_max_memuser>maxsize set_memlimitr&)r'_4GiBrold_max_memuseold_real_max_memusebigs rtest_set_memlimitzTestSupport.test_set_memlimits% ++%55 :{{U"$$T*  !3!3U;  !8!8%@fm$$uAY/  !3!3S[[A  !8!8#)D$$T*  !3!3S[[A  !8!8%@!/G &9G #"0G &9G #s D=E::Fctjd}|stjd}tjj |}tjj |s|j d|tjj|d}tjj |s|j d|dddh}tj|}|jtj|||dhztjj|d }|jtj|tj||dd hztjj|d }|jtj|tj||y) N abs_srcdirsrcdirz,cannot access Python source code directory: Modulesz landmark is missingz.gitrgbuildDocvenvObjects) sysconfigget_config_varrPrQabspathrRskipTestrYlistdirr&rcopy_python_src_ignore)r'src_dirlandmarkignorednamesrQs rtest_copy_python_src_ignorez'TestSupport.test_copy_python_src_ignoresr**<8..x8G''//'*ww~~g& MM%[* +77<<3ww~~h' MM&\)=? @ =) 7# 77G G9, .ww||GU+ 77bjj>NO GV#44 6ww||GY/ 77bjj>NO  "rr<)Hrrr classmethodrrr+r4r7r9r1skipr@rGrTrcrqrrequires_working_socketryr}rrrrr requires_forkrrrrrrrrrrrrrrrrrrr rrrr!r0 skipUnlessrrPrArequires_subprocessrXrequires_resourcerlroskipIfr~is_wasirwryr{rrrrrrrrrr r s<<<<5> 4Q X]]&'D(D/ !20,"%W$$&'%W$$&' %W$$&' )3  *W44 4* ",4R: 4 . *7 7 ,C," !  G /P6XY/JGB 4J;=W  =  D!W  " -# -Wu%"#&"#H NX__W**,DEX__W__&;< *=F *6 A = )3V;@!":.""rr __main__)rrkr9rPrrsr^rIr>rrrr1rtestr test.supportrrrrrrMTestCaser rmainrrrrs{   &"&&(   F "(##F "| zHMMOr