HEX
Server: Apache/2.4.65 (Debian)
System: Linux kubikelcreative 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User: www-data (33)
PHP: 8.4.13
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/test/__pycache__/test_support.cpython-39.pyc
a

kx�g�_�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlmZddlmZejZGdd�dej�Zdd�Zed	kr�e�dS)
�N)�support)�
script_helper)�
socket_helperc@s�eZdZdd�Zdd�Zdd�Ze�d�dd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Ze�eed �d!�d"d#��Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Z d6d7�Z!d8d9�Z"d:d;�Z#d<d=�Z$d>d?�Z%d@dA�Z&dBdC�Z'dDdE�Z(dFdG�Z)GdHdI�dI�Z*GdJdK�dK�Z+dLdM�Z,dNdO�Z-dPdQ�Z.e�eedR��o�eedS�dT�dUdV��Z/dfdXdY�Z0dZd[�Z1d\d]�Z2d^d_�Z3d`da�Z4dbdc�Z5ddde�Z6dWS)g�TestSupportcCs t�d�|�tjtjd�dS)N�ftplib�foo)r�
import_module�assertRaises�unittest�SkipTest��self�r�'/usr/lib/python3.9/test/test_support.py�test_import_modules
zTestSupport.test_import_modulecCst�d�dS)Nr)rZimport_fresh_modulerrrr�test_import_fresh_modulesz$TestSupport.test_import_fresh_modulecCs.|�t�|d�|j�|�tjtj|d�dS)N�test_get_attributer)�assertEqualrZ
get_attributerr	r
rrrrrrs�zTestSupport.test_get_attributezfailing buildbotscCs|�t��tj�dS�N)rrZget_original_stdout�sys�stdoutrrrr�test_get_original_stdout#sz$TestSupport.test_get_original_stdoutcCs2ddl}|�dtj�t�d�|�dtj�dS)Nr�sched)r�assertInr�modulesrZunload�assertNotIn)r
rrrr�test_unload's
zTestSupport.test_unloadcCsTttd��}Wd�n1s 0Yt�t�|�tj�t��t�t�dS)N�w)�open�TESTFNr�unlink�assertFalse�os�path�exists)r
�frrr�test_unlink-s

zTestSupport.test_unlinkcCsbtjd}tj�|d�}t�|�t�|�t�|�|�tj�|��t�	tdd��t�|�Wd�n1sv0Yt�|�t�|�t�
|tjtj
B�t�	tdd��t�|�Wd�n1s�0Y|�tj�|��t�|�t�|�t�
|d�t�	tdd��t�|�Wd�n1�sB0Y|�tj�|��dS)N�dZsubdir�verboser)rrr"r#�join�mkdir�rmtreer!r$�	swap_attr�chmod�stat�S_IRUSR�S_IXUSR)r
�dirpathZ
subdirpathrrr�test_rmtree4s(



(

(

*zTestSupport.test_rmtreec	Cs�td}t|d��}td|d�Wd�n1s40Ytj�dtj�t�	�zNt
t�}|�ttj�t
�t�|�ttj�Wtjd=t
�|�t
�d�ntjd=t
�|�t
�d�0dS)Nz.pyrzfoo = 1��filer�__pycache__)rr�printrr#�insertr"�curdir�	importlib�invalidate_caches�
__import__rrrZforgetrr r+)r
Zmod_filenamer%�modrrr�test_forgetLs *

�
zTestSupport.test_forgetcCst�tjdf�}|��dS)Nr)�socket�
create_serverr�HOST�close�r
�srrr�	test_HOST]szTestSupport.test_HOSTcCs$t��}t�tj|f�}|��dSr)rZfind_unused_portr>r?r@rA)r
ZportrCrrr�test_find_unused_portasz!TestSupport.test_find_unused_portcCs&t��}t�|�|��|��dSr)r>rZ	bind_portZlistenrArBrrr�test_bind_portfs
zTestSupport.test_bind_portc	Cs�t��}tj�|�}z�tj�|d�}|�tj�|��t�	|��.}|�
||�|�tj�|��Wd�n1st0Y|�tj�|��Wt�|�nt�|�0dS)z8Test that temp_dir() creates and destroys its directory.ZtempN)
�tempfile�mkdtempr"r#�realpathr)r!�isdirr�temp_dirr�
assertTruer+)r
�
parent_dirr#�	temp_pathrrr�
test_temp_dirns0zTestSupport.test_temp_dircCsPt���"}|�tj�|��Wd�n1s00Y|�tj�|��dS)zTest passing no path.N)rrKrLr"r#rJr!)r
rNrrr�test_temp_dir__path_none}s
0z$TestSupport.test_temp_dir__path_nonec	Csndd�}t��}tj�|�}z@|�tj�|��|�t||�|�tj�|��Wt	�
|�nt	�
|�0dS)z-Test passing a directory that already exists.cSs6t�|��}td��Wd�n1s(0YdS�Nzshould not get here)rrK�	Exception)r#rNrrr�
call_temp_dir�szMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dirN)rGrHr"r#rIrLrJr	�FileExistsError�shutilr+)r
rSr#rrr�*test_temp_dir__existing_dir__quiet_default�sz6TestSupport.test_temp_dir__existing_dir__quiet_defaultc	Cs�t��}tj�|�}z�t���Z}tj|dd��}|�||�Wd�n1sP0Ydd�|j	D�}Wd�n1s~0Y|�
tj�|��Wt�
|�nt�
|�0|�t|�d|�|d}|�
|�d|�d	��|�dS)
z=Test passing a directory that already exists with quiet=True.T��quietNcSsg|]}t|j��qSr��str�message��.0rrrr�
<listcomp>��zGTestSupport.test_temp_dir__existing_dir__quiet_true.<locals>.<listcomp>�rz5tests may fail, unable to create temporary directory �: )rGrHr"r#rIr�check_warningsrKr�warningsrLrJrUr+�len�
startswith)r
r#�recorderrNrc�warnrrr�'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
            with support.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�textwrapZdedentrrrr�test_temp_dir__forked_child�sz'TestSupport.test_temp_dir__forked_childc	Cs�t��}t���V}t�|��,}|�||�|�t��|�Wd�n1sN0YWd�n1sl0Y|�t��|�dSr)r"�getcwdrrK�
change_cwdr)r
�original_cwdrN�new_cwdrrr�test_change_cwd�s
LzTestSupport.test_change_cwdcCsht��}dd�}t���,}tj�|d�}|�t||�Wd�n1sJ0Y|�t��|�dS)z&Test passing a non-existent directory.cSs6t�|��}td��Wd�n1s(0YdSrQ)rrnrR)r#rprrr�call_change_cwd�szFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwd�does_not_existN)	r"rmrrKr#r)r	�FileNotFoundErrorr)r
rorrrMZnon_existent_dirrrr�!test_change_cwd__non_existent_dir�s
�"z-TestSupport.test_change_cwd__non_existent_dirc
Cs�t��}t����}tj�|d�}t���j}tj|dd��,}|�||�|�t��|�Wd�n1sj0Ydd�|j	D�}Wd�n1s�0YWd�n1s�0Y|�t
|�d|�|d}|�|�d	|�d
��|�dS)z6Test passing a non-existent directory with quiet=True.rsTrWNcSsg|]}t|j��qSrrYr\rrrr^�r_zMTestSupport.test_change_cwd__non_existent_dir__quiet_true.<locals>.<listcomp>r`r�Btests may fail, unable to change the current working directory to ra)
r"rmrrKr#r)rbrnrrcrdrLre)r
rorMZbad_dirrfrprcrgrrr�-test_change_cwd__non_existent_dir__quiet_true�s

.L
��z9TestSupport.test_change_cwd__non_existent_dir__quiet_truec	Cs�td}t���N}tj|dd��Wd�n1s60Ydd�|jD�}Wd�n1sd0Y|�t|�d|�|d}|�|�d	|�d
��|�dS)z0Check the warning message when os.chdir() fails.Z_does_not_existT)r#rXNcSsg|]}t|j��qSrrYr\rrrr^�r_z>TestSupport.test_change_cwd__chdir_warning.<locals>.<listcomp>r`rrvra)	rrrbrnrcrrdrLre)r
r#rfZmessages�msgrrr�test_change_cwd__chdir_warning�s
.
��z*TestSupport.test_change_cwd__chdir_warningcCsrt��}tjtd��(|�tj�t���t�Wd�n1sB0Y|�tj�	t��|�t��|�dS)N��name)
r"rmr�temp_cwdrrr#�basenamer!r$)r
�hererrr�
test_temp_cwds
6zTestSupport.test_temp_cwdcCsvt��}tjdd��>}|�||�|�tj�|��|�t��|�Wd�n1sX0Y|�t��|�dS)z Test passing None to temp_cwd().Nrz)	r"rmrr|ZassertNotEqualrLr#rJr)r
rorprrr�test_temp_cwd__name_none	s.z$TestSupport.test_temp_cwd__name_nonecCs|�t�dddd��d�dS)N��r`)r�r�r`z{1: 1, 2: 2, 3: 3})rrZsortdictrrrr�
test_sortdictszTestSupport.test_sortdictcCsTt��}|�t��}t�|d�Wd�n1s40Y|�|jjtj	�dS)Nsfoo)
rZmake_bad_fdr	�OSErrorr"�writerZ	exception�errnoZEBADF)r
�fd�cmrrr�test_make_bad_fds*zTestSupport.test_make_bad_fdcCsLtj|dddd�|�t��t�|d�Wd�n1s>0YdS)Nz	def classr`�)�lineno�offsetzx=1)rZcheck_syntax_errorr	�AssertionErrorrrrr�test_check_syntax_errorsz#TestSupport.test_check_syntax_errorcCs@ddl}t�d��|�d�Wd�n1s20YdS)NrZasyncore)r9rZCleanImportr)r
r9rrr�test_CleanImport szTestSupport.test_CleanImportcCsht�dd��,|�dtj�|�dtj�Wd�n1s>0Y|�dtj�|�dtj�dS)NrZbar)rZ
DirsOnSysPathrrr#rrrrr�test_DirsOnSysPath%s
,zTestSupport.test_DirsOnSysPathcCsDt���}td�Wd�n1s&0Y|�|��d�dS)N�hello�hello
)rZcaptured_stdoutr6r�getvalue)r
rrrr�test_captured_stdout,s
&z TestSupport.test_captured_stdoutcCsJt���}tdtjd�Wd�n1s,0Y|�|��d�dS)Nr�r3r�)rZcaptured_stderrr6r�stderrrr�)r
r�rrr�test_captured_stderr1s
,z TestSupport.test_captured_stderrcCsRt���*}|�d�|�d�t�}Wd�n1s80Y|�|d�dS)Nr�rr�)rZcaptured_stdinr��seek�inputr)r
�stdinZcapturedrrr�test_captured_stdin6s



$zTestSupport.test_captured_stdincCst��dSr)rZ
gc_collectrrrr�test_gc_collect>szTestSupport.test_gc_collectcCs|�t��t�dSr)ZassertIsInstancerZpython_is_optimized�boolrrrr�test_python_is_optimizedAsz$TestSupport.test_python_is_optimizedcCsGdd�d�}|�}d|_t�|dd��*}|�|jd�|�|d�Wd�n1sX0Y|�|jd�t�|dd��(}|�|jd�|�|�Wd�n1s�0Y|�t|d��t�|dd��|`Wd�n1s�0Y|�t|d��dS)Nc@seZdZdS)z'TestSupport.test_swap_attr.<locals>.ObjN)�__name__�
__module__�__qualname__rrrr�ObjEsr�r`�xr��y)r�rr,rr��assertIsNoner!�hasattr)r
r��objr�r�rrr�test_swap_attrDs*("zTestSupport.test_swap_attrcCs�ddi}t�|dd��,}|�|dd�|�|d�Wd�n1sH0Y|�|dd�t�|dd��*}|�|dd�|�|�Wd�n1s�0Y|�d|�t�|dd��|d=Wd�n1s�0Y|�d|�dS)Nr�r`r�r�)rZ	swap_itemrr�r)r
�Dr�r�rrr�test_swap_itemUs*($zTestSupport.test_swap_itemc@seZdZdZdZdZdZdS)zTestSupport.RefClassN)r�r�r��
attribute1�
attribute2Z_hidden_attribute1�__magic_1__rrrr�RefClasscsr�c@seZdZdZdZdZdZdS)zTestSupport.OtherClassN)r�r�r�r��
attribute3r��__magic_2__rrrr�
OtherClassisr�cCsBt�|j|j�}|�dh|�t�|j|j�}|�ddh|�dS)Nr�r�r�)r�detect_api_mismatchr�r�r)r
�
missing_itemsrrr�test_detect_api_mismatchos��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__ignorexs
�
�z,TestSupport.test_detect_api_mismatch__ignorecCsXdh}dh}tj|t||d�ddh}hd�}tj|td||d�|�ttj|t�dS)NZtempdir�template)�extra�	blacklistZTextTestResultZinstallHandler>ZTestProgramZ
BaseTestSuiteZ
load_tests)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��}|dkr"t�d�t��}t��tj}tj}z�dt_t	�
�}t��|krd|�d�tj
}z|t_
t��W|t_
n|t_
0tjr�q�t�d�qNd|}|�||���|�tj�W|t_n|t_0t��dS)NrFZtimeoutg�������?z2Warning -- reap_children() reaped child process %s)rZ
reap_childrenr"ri�_exit�time�	monotonicZ
SHORT_TIMEOUTZenvironment_altered�io�StringIOZfailr�
__stderr__�sleeprr�rL)r
�pidZt0ZdeadlineZwas_alteredr��
old_stderrrxrrr�test_reap_children�s2


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()))rjcSs i|]\}}|�d�s||�qS)ZPYTHON)re)r]�key�valuerrr�
<dictcomp>�s
�z-TestSupport.check_options.<locals>.<dictcomp>T)rr�Zuniversal_newlines�envr)r�
executabler"�environ�items�
subprocess�run�PIPEZDEVNULLrr�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�q\1s�0Yq\|�gd�ddg�dS)Nz-B�-sz-S�-Ez-vz-bz-q�-Iz-bbz-vvv�-Wignore�-X�dev)r�r�r�ZfaulthandlerZ
importtimeZshowrefcount�tracemallocz
tracemalloc=3��optsZargs_from_interpreter_flags)r�r�r��ZsubTestr��r
r�rrr� test_args_from_interpreter_flags�s2�,�z,TestSupport.test_args_from_interpreter_flagsc	CsTgdgdgdgfD]<}|j|d��|�|d�Wd�q1sD0YqdS)Nz-Oz-OOz-OOOOr�Z!optim_args_from_interpreter_flagsr�r�rrr�&test_optim_args_from_interpreter_flags�s�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�n1�s�0Yt�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�n1�s�0YdS)Nc@seZdZdd�Zdd�ZdS)z)TestSupport.test_match_test.<locals>.TestcSs
||_dSr��test_id)r
r�rrr�__init__	sz2TestSupport.test_match_test.<locals>.Test.__init__cSs|jSrr�rrrr�idsz,TestSupport.test_match_test.<locals>.Test.idN)r�r�r�r�r�rrrr�Testsr�z"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)Zignore_patterns)rr,Zset_match_testsrLZ
match_testr�r!)r
r�r�Z
test_chdirrrr�test_match_testsz
0zTestSupport.test_match_testc	CsNt��}t�ttj�}zt��}Wt�|�nt�|�0|�||d�dS)Nr`)rZfd_countr"r�__file__�O_RDONLYrAr)r
�startr�Zmorerrr�
test_fd_countps
zTestSupport.test_fd_countcCsFt��}tj}z|t_t�|�W|t_n|t_0|�|��|�dSr)r�r�rr�rZ
print_warningrr�)r
rxr�r�r�rrr�check_print_warning|szTestSupport.check_print_warningcCs|�dd�|�dd�dS)NrxzWarning -- msg
za
bzWarning -- a
Warning -- b
)r�rrrr�test_print_warning�s��zTestSupport.test_print_warning)N)7r�r�r�rrrr
�skiprrr&r2r=rDrErFrOrPrVrhZ
skipUnlessr�r"rlrqrurwryrr�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�rrrrrsh


		�
/
"ircCstg}tj|�dSr)rrZrun_unittest)Ztestsrrr�	test_main�sr��__main__)r�r9r�r"rUr>r.r�rrGrkr�r
�testrZtest.supportrrrZTestCaserr�r�rrrr�<module>s2