Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.14.245.203
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_support.cpython-310.pyc
o

abVe�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZddlmZddlmZddlmZddlmZejZGdd	�d	ej�Zed
krre��dSdS)�N)�support)�
import_helper)�	os_helper)�
script_helper)�
socket_helper)�warnings_helperc@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	e
�d
�dd��Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Ze
�eed&�d'�d(d)��Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Z d4d5�Z!d6d7�Z"d8d9�Z#d:d;�Z$d<d=�Z%d>d?�Z&d@dA�Z'dBdC�Z(dDdE�Z)dFdG�Z*dHdI�Z+dJdK�Z,dLdM�Z-GdNdO�dO�Z.GdPdQ�dQ�Z/dRdS�Z0dTdU�Z1dVdW�Z2e
�eedX�o�eedY�dZ�d[d\��Z3dld^d_�Z4d`da�Z5dbdc�Z6ddde�Z7dfdg�Z8dhdi�Z9djdk�Z:d]S)m�TestSupportcCsDttj�}tjddd�|_tjddd�|_ttj�|dks J�dS)Nztest.support.warnings_helperz.*used in test_support.*)Zlikeztest.test_supportz!.*You should NOT be seeing this.*�)�len�warnings�filtersrZignore_deprecations_from�_warnings_helper_token�_test_support_token��clsZorig_filter_len�r�:/usr/local/python-3.10/lib/python3.10/test/test_support.py�
setUpClasss
��zTestSupport.setUpClasscCs4ttj�}t�|j|j�ttj�|dksJ�dS)Nr	)r
rrrZclear_ignored_deprecationsr
rrrrr�
tearDownClass&s
�zTestSupport.tearDownClasscCsdtjdd��}t��t�dt�dd�|D�}Wd�n1s"wY|�t|�d|�dS)z9Test support.ignore_deprecations_from() silences warningsT)�recordzYou should NOT be seeing this.cS�g|]}t|j��qSr��str�message��.0�wrrr�
<listcomp>4�zDTestSupport.test_ignored_deprecations_are_silent.<locals>.<listcomp>Nr)r�catch_warningsrZ_warn_about_deprecation�warn�DeprecationWarning�assertEqualr
)�selfZwarning_objs�messagesrrr�$test_ignored_deprecations_are_silent/s�z0TestSupport.test_ignored_deprecations_are_silentcCs t�d�|�tjtjd�dS)N�ftplib�foo)r�
import_module�assertRaises�unittest�SkipTest�r#rrr�test_import_module7s
�zTestSupport.test_import_modulecCst�d�dS)Nr&)rZimport_fresh_moduler,rrr�test_import_fresh_module<sz$TestSupport.test_import_fresh_modulecCs.|�t�|d�|j�|�tjtj|d�dS)N�test_get_attributer')r"rZ
get_attributer/r)r*r+r,rrrr/?s�zTestSupport.test_get_attributezfailing buildbotscCs|�t��tj�dS�N)r"rZget_original_stdout�sys�stdoutr,rrr�test_get_original_stdoutDsz$TestSupport.test_get_original_stdoutcCs2ddl}|�dtj�t�d�|�dtj�dS)Nr�sched)r4�assertInr1�modulesrZunload�assertNotIn)r#r4rrr�test_unloadHs
zTestSupport.test_unloadcCsXttddd��}Wd�n1swYt�t�|�tj�t��t�t�dS)Nr�utf-8��encoding)�open�TESTFNr�unlink�assertFalse�os�path�exists)r#�frrr�test_unlinkNs�
zTestSupport.test_unlinkcCs`tjd}tj�|d�}t�|�t�|�t�|�|�tj�|��t	�
t	dd��
t�|�Wd�n1s;wYt�|�t�|�t�|tj
tjB�t	�
t	dd��
t�|�Wd�n1skwY|�tj�|��t�|�t�|�t�|d�t	�
t	dd��
t�|�Wd�n1s�wY|�tj�|��dS)N�dZsubdir�verboser)rr=r@rA�join�mkdir�rmtreer?rBr�	swap_attr�chmod�stat�S_IRUSR�S_IXUSR)r#�dirpathZ
subdirpathrrr�test_rmtreeUs.



�

�

�zTestSupport.test_rmtreec	Cs�td}t|ddd��}td|d�Wd�n1swYtj�dtj�t�	�z(t
t�}|�ttj�t
�t�|�ttj�Wtjd=t�|�t�d�dStjd=t�|�t�d�w)	Nz.pyrr9r:zfoo = 1��filer�__pycache__)r=r<�printr1rA�insertr@�curdir�	importlib�invalidate_caches�
__import__r5r6rZforgetr7rr>rI)r#Zmod_filenamerC�modrrr�test_forgetms"�

�
zTestSupport.test_forgetcCst�tjdf�}|��dS)Nr)�socket�
create_serverr�HOST�close�r#�srrr�	test_HOST~szTestSupport.test_HOSTcCs$t��}t�tj|f�}|��dSr0)rZfind_unused_portr\r]r^r_)r#�portrarrr�test_find_unused_port�sz!TestSupport.test_find_unused_portcCs&t��}t�|�|��|��dSr0)r\rZ	bind_port�listenr_r`rrr�test_bind_port�s
zTestSupport.test_bind_portc	Cs�t��}tj�|�}zEtj�|d�}|�tj�|��t�	|��}|�
||�|�tj�|��Wd�n1s:wY|�tj�|��Wt�|�dSt�|�w)z8Test that temp_dir() creates and destroys its directory.ZtempN)
�tempfile�mkdtempr@rA�realpathrGr?�isdirr�temp_dirr"�
assertTruerI)r#�
parent_dirrA�	temp_pathrrr�
test_temp_dir�s�zTestSupport.test_temp_dircCsPt���}|�tj�|��Wd�n1swY|�tj�|��dS)zTest passing no path.N)rrkrlr@rArjr?)r#rnrrr�test_temp_dir__path_none�s
�z$TestSupport.test_temp_dir__path_nonec	Csldd�}t��}tj�|�}z!|�tj�|��|�t||�|�tj�|��Wt	�
|�dSt	�
|�w)z-Test passing a directory that already exists.cS�(t�|��}td��1s
wYdS�Nzshould not get here)rrk�	Exception)rArnrrr�
call_temp_dir���zMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dirN)rgrhr@rArirlrjr)�FileExistsError�shutilrI)r#rtrArrr�*test_temp_dir__existing_dir__quiet_default�sz6TestSupport.test_temp_dir__existing_dir__quiet_defaultc	Cs�t��}tj�|�}zIt���-}tj|dd��}|�	||�Wd�n1s(wYdd�|j
D�}Wd�n1s?wY|�tj�|��Wt
�|�nt
�|�w|�	t|�d|�|d}|�|�d|�d	��|�dS)
z=Test passing a directory that already exists with quiet=True.T��quietNcSrrrrrrrr�rzGTestSupport.test_temp_dir__existing_dir__quiet_true.<locals>.<listcomp>�rz5tests may fail, unable to create temporary directory �: )rgrhr@rArir�check_warningsrrkr"rrlrjrwrIr
�
startswith)r#rA�recorderrnrr rrr�'test_temp_dir__existing_dir__quiet_true�s$
��
��z3TestSupport.test_temp_dir__existing_dir__quiet_true�forkztest requires os.forkcCst�dt�d��dS)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)rZassert_python_ok�textwrap�dedentr,rrr�test_temp_dir__forked_child�sz'TestSupport.test_temp_dir__forked_childc	Cs�t��}t���+}t�|��}|�||�|�t��|�Wd�n1s'wYWd�n1s6wY|�t��|�dSr0)r@�getcwdrrk�
change_cwdr")r#�original_cwdrn�new_cwdrrr�test_change_cwd�s
���zTestSupport.test_change_cwdcCsht��}dd�}t���}tj�|d�}|�t||�Wd�n1s%wY|�t��|�dS)z&Test passing a non-existent directory.cSrqrr)rr�rs)rAr�rrr�call_change_cwd�ruzFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwd�does_not_existN)	r@r�rrkrArGr)�FileNotFoundErrorr")r#r�r�rmZnon_existent_dirrrr�!test_change_cwd__non_existent_dir�s
��z-TestSupport.test_change_cwd__non_existent_dirc
Cs�t��}t���P}tj�|d�}t���5}tj|dd��}|�	||�|�	t��|�Wd�n1s5wYdd�|j
D�}Wd�n1sLwYWd�n1s[wY|�	t|�d|�|d}|�|�
d	|�d
��|�dS)z6Test passing a non-existent directory with quiet=True.r�TryNcSrrrrrrrrrzMTestSupport.test_change_cwd__non_existent_dir__quiet_true.<locals>.<listcomp>r{r�Btests may fail, unable to change the current working directory to r|)r@r�rrkrArGrr}r�r"rr
rlr~)r#r�rmZbad_dirrr�rr rrr�-test_change_cwd__non_existent_dir__quiet_true�s&

����
��z9TestSupport.test_change_cwd__non_existent_dir__quiet_truec	Cs�td}t���'}tj|dd��Wd�n1swYdd�|jD�}Wd�n1s2wY|�t|�d|�|d}|�|�	d	|�d
��|�dS)z0Check the warning message when os.chdir() fails.Z_does_not_existT)rArzNcSrrrrrrrrrz>TestSupport.test_change_cwd__chdir_warning.<locals>.<listcomp>r{rr�r|)
r=rr}rr�rr"r
rlr~)r#rArr$�msgrrr�test_change_cwd__chdir_warnings
��
��z*TestSupport.test_change_cwd__chdir_warningcCsrt��}tjtd��|�tj�t���t�Wd�n1s!wY|�tj�	t��|�t��|�dS)N��name)
r@r�r�temp_cwdr=r"rA�basenamer?rB)r#�hererrr�
test_temp_cwd#s�zTestSupport.test_temp_cwdcCsvt��}tjdd��}|�||�|�tj�|��|�t��|�Wd�n1s,wY|�t��|�dS)z Test passing None to temp_cwd().Nr�)	r@r�rr�ZassertNotEqualrlrArjr")r#r�r�rrr�test_temp_cwd__name_none+s�z$TestSupport.test_temp_cwd__name_nonecCs|�t�dddd��d�dS)N�r	r{)r�r	r{z{1: 1, 2: 2, 3: 3})r"rZsortdictr,rrr�
test_sortdict4szTestSupport.test_sortdictcCsTt��}|�t��}t�|d�Wd�n1swY|�|jjtj	�dS)Nsfoo)
rZmake_bad_fdr)�OSErrorr@�writer"�	exception�errno�EBADF)r#�fd�cmrrr�test_make_bad_fd7s
�zTestSupport.test_make_bad_fdcCsNtj|dddd�|�t��t�|d�Wd�dS1s wYdS)Nz	def classr{�)�lineno�offsetzx=1)rZcheck_syntax_errorr)�AssertionErrorr,rrr�test_check_syntax_error=s"�z#TestSupport.test_check_syntax_errorcCsBddl}t�d��|�d�Wd�dS1swYdS)NrZpprint)rWrZCleanImportr()r#rWrrr�test_CleanImportBs"�zTestSupport.test_CleanImportcCsht�dd��|�dtj�|�dtj�Wd�n1swY|�dtj�|�dtj�dS)Nr'Zbar)rZ
DirsOnSysPathr5r1rAr7r,rrr�test_DirsOnSysPathGs�zTestSupport.test_DirsOnSysPathcCsDt���}td�Wd�n1swY|�|��d�dS)N�hello�hello
)rZcaptured_stdoutrTr"�getvalue)r#r2rrr�test_captured_stdoutNs

�z TestSupport.test_captured_stdoutcCsJt���}tdtjd�Wd�n1swY|�|��d�dS)Nr�rQr�)rZcaptured_stderrrTr1�stderrr"r�)r#r�rrr�test_captured_stderrSs
�z TestSupport.test_captured_stderrcCsRt���}|�d�|�d�t�}Wd�n1swY|�|d�dS)Nr�rr�)rZcaptured_stdinr��seek�inputr")r#�stdinZcapturedrrr�test_captured_stdinXs


�zTestSupport.test_captured_stdincCst��dSr0)r�
gc_collectr,rrr�test_gc_collect`szTestSupport.test_gc_collectcCs|�t��t�dSr0)ZassertIsInstancerZpython_is_optimized�boolr,rrr�test_python_is_optimizedcsz$TestSupport.test_python_is_optimizedcCsGdd�d�}|�}d|_t�|dd��}|�|jd�|�|d�Wd�n1s,wY|�|jd�t�|dd��}|�|jd�|�|�Wd�n1sVwY|�t|d��t�|dd��
|`Wd�n1swwY|�t|d��dS)Nc@seZdZdS)z'TestSupport.test_swap_attr.<locals>.ObjN)�__name__�
__module__�__qualname__rrrr�Objgsr�r{�xr��y)r�rrJr"r��assertIsNoner?�hasattr)r#r��objr�r�rrr�test_swap_attrfs"���zTestSupport.test_swap_attrcCs�ddi}t�|dd��}|�|dd�|�|d�Wd�n1s$wY|�|dd�t�|dd��}|�|dd�|�|�Wd�n1sPwY|�d|�t�|dd��|d=Wd�n1spwY|�d|�dS)Nr�r{r�r�)rZ	swap_itemr"r�r7)r#�Dr�r�rrr�test_swap_itemws���zTestSupport.test_swap_itemc@�eZdZdZdZdZdZdS)zTestSupport.RefClassN)r�r�r��
attribute1�
attribute2Z_hidden_attribute1�__magic_1__rrrr�RefClass��
r�c@r�)zTestSupport.OtherClassN)r�r�r�r��
attribute3r��__magic_2__rrrr�
OtherClass�r�r�cCsBt�|j|j�}|�dh|�t�|j|j�}|�ddh|�dS)Nr�r�r�)r�detect_api_mismatchr�r�r")r#�
missing_itemsrrr�test_detect_api_mismatch�s��z$TestSupport.test_detect_api_mismatchcCsPgd�}tj|j|j|d�}|�t�|�tj|j|j|d�}|�t�|�dS)N)r�r�r�Z
not_in_either)�ignore)rr�r�r�r"�set)r#r�r�rrr� test_detect_api_mismatch__ignore�s
�
�z,TestSupport.test_detect_api_mismatch__ignorecCsXdh}dh}tj|t||d�ddh}hd�}tj|td||d�|�ttj|t�dS)N�tempdir�template)�extra�not_exportedZTextTestResultZinstallHandler>ZTestProgramZ
load_testsZ
BaseTestSuite)zunittest.resultz
unittest.casezunittest.suitezunittest.loaderz
unittest.mainzunittest.runnerzunittest.signalszunittest.async_case)rZcheck__all__rgr*r)r�)r#r�r�rrr�test_check__all__�s ��	zTestSupport.test_check__all__�waitpid�WNOHANGz need os.waitpid() and os.WNOHANGcCs�t��t��}|dkrt�d�t��}t��tj}tj}zHdt_t	�
�}	t��|kr3|�d�tj
}z|t_
t��W|t_
n|t_
wtjrKqQt�d�q(d|}|�||���|�tj�W|t_n|t_wt��dS)NrFT�timeoutg�������?z2Warning -- reap_children() reaped child process %s)r�
reap_childrenr@r��_exit�time�	monotonicZ
SHORT_TIMEOUTZenvironment_altered�io�StringIOZfailr1�
__stderr__�sleepr5r�rl)r#�pid�t0�deadlineZwas_alteredr��
old_stderrr�rrr�test_reap_children�s6



�zTestSupport.test_reap_childrenNcCs�d|�d|�d�}tjg|�d�|�}dd�tj��D�}tj|tjtjd|d�}|dur/|}|�	|j
��t|��|�	|j
d	�dS)
Nzfrom test.support import z
; print(repr(z()))r�cSs i|]\}}|�d�s||�qS)ZPYTHON)r~)r�key�valuerrr�
<dictcomp>�s�z-TestSupport.check_options.<locals>.<dictcomp>T)r2r��universal_newlines�envr)r1�
executabler@�environ�items�
subprocess�run�PIPE�DEVNULLr"r2�rstrip�repr�
returncode)r#�args�func�expected�code�cmdr��procrrr�
check_options�s�zTestSupport.check_optionscCs�gdgdgdgdgdgdgdgdgd	gd
gdgdd
ggd�ddgddgddgddgddgfD]}|j|d��|�|d�Wd�n1sGwYq.|�gd�ddg�dS)Nz-B�-sz-S�-Ez-vz-bz-q�-Iz-bbz-vvv�-Wignore�-X�dev)rrr�faulthandler�
importtime�showrefcount�tracemallocz
tracemalloc=3��optsZargs_from_interpreter_flags)rrr��ZsubTestr��r#r
rrr� test_args_from_interpreter_flags�s6����z,TestSupport.test_args_from_interpreter_flagsc	CsTgdgdgdgfD]}|j|d��|�|d�Wd�n1s"wYq	dS)Nz-Oz-OOz-OOOOr	Z!optim_args_from_interpreter_flagsrrrrr�&test_optim_args_from_interpreter_flagss����z2TestSupport.test_optim_args_from_interpreter_flagscCs�Gdd�d�}|d�}|d�}t�tdd���t�g�|�t�|��|�t�|��t�dd�|�t�|��|�t�|��t�|��gd�|�t�|��|�t�|��t�dgd�|�t�|��|�t�|��t�dgd�|�t�|��|�t�|��t�dgd�|�t�|��t�d	gd�|�t�|��t�d
gd�|�t�|��|�t�|��t�|��|��gd�|�t�|��|�t�|��t�ddgd�|�t�|��|�t�|��Wd�n1s�wYt�tdd���tjgd
�|�t�|��|�t�|��t�dd�|�t�|��|�t�|��t�d|��g�|�t�|��|�t�|��t�ddg�|�t�|��|�t�|��t�ddg�|�t�|��|�t�|��t�ddg�|�t�|��t�dd	g�|�t�|��t�dd
g�|�t�|��|�t�|��t�d|��|��g�|�t�|��|�t�|��t�dddg�|�t�|��|�t�|��Wd�dS1�s�wYdS)Nc@seZdZdd�Zdd�ZdS)z)TestSupport.test_match_test.<locals>.TestcSs
||_dSr0��test_id)r#rrrr�__init__+s
z2TestSupport.test_match_test.<locals>.Test.__init__cSs|jSr0rr,rrr�id.sz,TestSupport.test_match_test.<locals>.Test.idN)r�r�r�rrrrrr�Test*srz"test.test_os.FileTests.test_accessz'test.test_os.Win32ErrorTests.test_chdirZ_match_test_funcZtest_osztest_*Z	filetestsZ	FileTestsz*test_os.*.test_*�test_accessZ	DONTMATCH)�ignore_patterns)rrJZset_match_testsrlZ
match_testrr?)r#rrZ
test_chdirrrr�test_match_test)s~
�/$�zTestSupport.test_match_testc	CsNt��}t�ttj�}zt��}Wt�|�nt�|�w|�||d�dS)Nr{)rZfd_countr@r<�__file__�O_RDONLYr_r")r#�startr�Zmorerrr�
test_fd_count�s
zTestSupport.test_fd_countcCsFt��}tj}z
|t_t�|�W|t_n|t_w|�|��|�dSr0)r�r�r1r�rZ
print_warningr"r�)r#r�r�r�r�rrr�check_print_warning�szTestSupport.check_print_warningcCs|�dd�|�dd�dS)Nr�zWarning -- msg
za
bzWarning -- a
Warning -- b
)rr,rrr�test_print_warning�s��zTestSupport.test_print_warningr0);r�r�r��classmethodrrr%r-r.r/r*�skipr3r8rDrPr[rbrdrfrorprxr�Z
skipUnlessr�r@r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
rrrrrrrrrrst





		�

/"ir�__main__)r�rWr�r@rwr\rLr�r1rgr�r�r*r�testrZtest.supportrrrrrr=ZTestCaserr��mainrrrr�<module>s<3�
© 2025 GrazzMean