%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/2318/lib/python3.8/test/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/2318/lib/python3.8/test/__pycache__/test_support.cpython-38.pyc

U

k�]ev`�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZejZGdd�de
j�Zdd�Zedkr�e�dS)	�N)�support)�
script_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.8/test/test_support.py�test_import_modules
zTestSupport.test_import_modulecCst�d�dS)Nr)rZimport_fresh_modulerr
r
r�test_import_fresh_modulesz$TestSupport.test_import_fresh_modulecCs.|�t�|d�|j�|�tjtj|d�dS)N�test_get_attributer)�assertEqualrZ
get_attributerrr	r
rr
r
rrs�zTestSupport.test_get_attributezfailing buildbotscCs|�t��tj�dS�N)rrZget_original_stdout�sys�stdoutrr
r
r�test_get_original_stdout#sz$TestSupport.test_get_original_stdoutcCs2ddl}|�dtj�t�d�|�dtj�dS)Nr�sched)r�assertInr�modulesrZunload�assertNotIn)rrr
r
r�test_unload's
zTestSupport.test_unloadc	Cs@ttd��}W5QRXt�t�|�tj�t��t�t�dS)N�w)�open�TESTFNr�unlink�assertFalse�os�path�exists)r�fr
r
r�test_unlink-s


zTestSupport.test_unlinkc	Cs$tjd}tj�|d�}t�|�t�|�t�|�|�tj�|��t�	tdd��t�|�W5QRXt�|�t�|�t�
|tjtj
B�t�	tdd��t�|�W5QRX|�tj�|��t�|�t�|�t�
|d�t�	tdd��t�|�W5QRX|�tj�|��dS)N�dZsubdir�verboser)rrr!r"�join�mkdir�rmtreer r#�	swap_attr�chmod�stat�S_IRUSR�S_IXUSR)r�dirpathZ
subdirpathr
r
r�test_rmtree4s(







zTestSupport.test_rmtreec	Cs�td}t|d��}td|d�W5QRXtj�dtj�t�	�z2t
t�}|�ttj�t
�t�|�ttj�W5tjd=t
�|�t
�d�XdS)Nz.pyrzfoo = 1��filer�__pycache__)rr�printrr"�insertr!�curdir�	importlib�invalidate_cachesrrr*�
__import__rrZforgetr)rZmod_filenamer$�modr
r
r�test_forgetLs

zTestSupport.test_forgetcCst�tjdf�}|��dS)Nr)�socket�
create_serverr�HOST�close�r�sr
r
r�	test_HOST]szTestSupport.test_HOSTcCs$t��}t�tj|f�}|��dSr)rZfind_unused_portr=r>r?r@)rZportrBr
r
r�test_find_unused_portasz!TestSupport.test_find_unused_portcCs&t��}t�|�|��|��dSr)r=rZ	bind_portZlistenr@rAr
r
r�test_bind_portfs
zTestSupport.test_bind_portc	Cs�t��}tj�|�}zjtj�|d�}|�tj�	|��t�
|��$}|�||�|�tj�	|��W5QRX|�tj�	|��W5t�|�XdS)z8Test that temp_dir() creates and destroys its directory.ZtempN)
�tempfile�mkdtempr!r"�realpathrr*r(r �isdir�temp_dirr�
assertTrue)r�
parent_dirr"�	temp_pathr
r
r�
test_temp_dirnszTestSupport.test_temp_dirc	Cs<t���}|�tj�|��W5QRX|�tj�|��dS)zTest passing no path.N)rrJrKr!r"rIr )rrMr
r
r�test_temp_dir__path_none}s
z$TestSupport.test_temp_dir__path_nonec	Csddd�}t��}tj�|�}z6|�tj�|��|�	t
||�|�tj�|��W5t�|�XdS)z-Test passing a directory that already exists.c	Ss"t�|��}td��W5QRXdS�Nzshould not get here)rrJ�	Exception)r"rMr
r
r�
call_temp_dir�szMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dirN)rFrGr!r"rH�shutilr*rKrIr�FileExistsError)rrRr"r
r
r�*test_temp_dir__existing_dir__quiet_default�sz6TestSupport.test_temp_dir__existing_dir__quiet_defaultc
Cs�t��}tj�|�}z`t���<}tj	|dd��}|�
||�W5QRXdd�|jD�}W5QRX|�tj�
|��W5t�|�X|�
t|�d|�|d}|�|�d|�d��|�d	S)
z=Test passing a directory that already exists with quiet=True.T��quietcSsg|]}t|j��qSr
��str�message��.0rr
r
r�
<listcomp>�szGTestSupport.test_temp_dir__existing_dir__quiet_true.<locals>.<listcomp>�rz5tests may fail, unable to create temporary directory �: N)rFrGr!r"rHrSr*r�check_warningsrJr�warningsrKrI�len�
startswith)rr"�recorderrMra�warnr
r
r�'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 (child has pid == 0)

                    # wait for the child to terminate
                    (pid, status) = os.waitpid(pid, 0)
                    if status != 0:
                        raise AssertionError(f"Child process failed with exit "
                                             f"status indication 0x{status:x}.")

                    # 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�textwrapZdedentrr
r
r�test_temp_dir__forked_child�sz'TestSupport.test_temp_dir__forked_childc
Csbt��}t���8}t�|��"}|�||�|�t��|�W5QRXW5QRX|�t��|�dSr)r!�getcwdrrJ�
change_cwdr)r�original_cwdrM�new_cwdr
r
r�test_change_cwd�s
$zTestSupport.test_change_cwdc	CsTt��}dd�}t���"}tj�|d�}|�t||�W5QRX|�t��|�dS)z&Test passing a non-existent directory.c	Ss"t�|��}td��W5QRXdSrP)rrlrQ)r"rnr
r
r�call_change_cwd�szFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwd�does_not_existN)	r!rkrrJr"r(r�FileNotFoundErrorr)rrmrprLZnon_existent_dirr
r
r�!test_change_cwd__non_existent_dir�s
�z-TestSupport.test_change_cwd__non_existent_dircCs�t��}t���n}tj�|d�}t���L}tj|dd��"}|�||�|�t��|�W5QRXdd�|j	D�}W5QRXW5QRX|�t
|�d|�|d}|�|�d|�d	��|�d
S)z6Test passing a non-existent directory with quiet=True.rqTrVcSsg|]}t|j��qSr
rXr[r
r
rr]�szMTestSupport.test_change_cwd__non_existent_dir__quiet_true.<locals>.<listcomp>r^r�Btests may fail, unable to change the current working directory to r_N)
r!rkrrJr"r(r`rlrrarbrKrc)rrmrLZbad_dirrdrnrarer
r
r�-test_change_cwd__non_existent_dir__quiet_true�s

$�z9TestSupport.test_change_cwd__non_existent_dir__quiet_truec
Cs~td}t���0}tj|dd��W5QRXdd�|jD�}W5QRX|�t|�d|�|d}|�|�d|�d	��|�d
S)z0Check the warning message when os.chdir() fails.Z_does_not_existT)r"rWcSsg|]}t|j��qSr
rXr[r
r
rr]�sz>TestSupport.test_change_cwd__chdir_warning.<locals>.<listcomp>r^rrtr_N)	rrr`rlrarrbrKrc)rr"rdZmessages�msgr
r
r�test_change_cwd__chdir_warning�s

�z*TestSupport.test_change_cwd__chdir_warningc	Cs^t��}tjtd��|�tj�t���t�W5QRX|�tj�	t��|�t��|�dS)N��name)
r!rkr�temp_cwdrrr"�basenamer r#)r�herer
r
r�
test_temp_cwds
"zTestSupport.test_temp_cwdc	Csbt��}tjdd��4}|�||�|�tj�|��|�t��|�W5QRX|�t��|�dS)z Test passing None to temp_cwd().Nrx)	r!rkrrzZassertNotEqualrKr"rIr)rrmrnr
r
r�test_temp_cwd__name_nonesz$TestSupport.test_temp_cwd__name_nonecCs|�t�dddd��d�dS)N��r^)rr�r^z{1: 1, 2: 2, 3: 3})rrZsortdictrr
r
r�
test_sortdictszTestSupport.test_sortdictc	Cs@t��}|�t��}t�|d�W5QRX|�|jjtj	�dS)Nsfoo)
rZmake_bad_fdr�OSErrorr!�writerZ	exception�errnoZEBADF)r�fd�cmr
r
r�test_make_bad_fdszTestSupport.test_make_bad_fdc	Cs8tj|dddd�|�t��t�|d�W5QRXdS)Nz	def classr^�)�lineno�offsetzx=1)rZcheck_syntax_errorr�AssertionErrorrr
r
r�test_check_syntax_errorsz#TestSupport.test_check_syntax_errorc	Cs,ddl}t�d��|�d�W5QRXdS)NrZasyncore)r8rZCleanImportr)rr8r
r
r�test_CleanImport#szTestSupport.test_CleanImportc	CsTt�dd��"|�dtj�|�dtj�W5QRX|�dtj�|�dtj�dS)NrZbar)rZ
DirsOnSysPathrrr"rrr
r
r�test_DirsOnSysPath(s
zTestSupport.test_DirsOnSysPathc	Cs0t���}td�W5QRX|�|��d�dS)N�hello�hello
)rZcaptured_stdoutr5r�getvalue)rrr
r
r�test_captured_stdout/s
z TestSupport.test_captured_stdoutc	Cs6t���}tdtjd�W5QRX|�|��d�dS)Nr�r2r�)rZcaptured_stderrr5r�stderrrr�)rr�r
r
r�test_captured_stderr4s
z TestSupport.test_captured_stderrc	Cs>t��� }|�d�|�d�t�}W5QRX|�|d�dS)Nr�rr�)rZcaptured_stdinr��seek�inputr)r�stdinZcapturedr
r
r�test_captured_stdin9s



zTestSupport.test_captured_stdincCst��dSr)rZ
gc_collectrr
r
r�test_gc_collectAszTestSupport.test_gc_collectcCs|�t��t�dSr)ZassertIsInstancerZpython_is_optimized�boolrr
r
r�test_python_is_optimizedDsz$TestSupport.test_python_is_optimizedc	Cs�Gdd�d�}|�}d|_t�|dd�� }|�|jd�|�|d�W5QRX|�|jd�t�|dd��}|�|jd�|�|�W5QRX|�t|d��t�|dd��
|`W5QRX|�t|d��dS)Nc@seZdZdS)z'TestSupport.test_swap_attr.<locals>.ObjN)�__name__�
__module__�__qualname__r
r
r
r�ObjHsr�r^�xr��y)r�rr+rr��assertIsNoner �hasattr)rr��objr�r�r
r
r�test_swap_attrGszTestSupport.test_swap_attrc	Cs�ddi}t�|dd��"}|�|dd�|�|d�W5QRX|�|dd�t�|dd�� }|�|dd�|�|�W5QRX|�d|�t�|dd��|d=W5QRX|�d|�dS)Nr�r^r�r�)rZ	swap_itemrr�r)r�Dr�r�r
r
r�test_swap_itemXszTestSupport.test_swap_itemc@seZdZdZdZdZdZdS)zTestSupport.RefClassN)r�r�r��
attribute1�
attribute2Z_hidden_attribute1�__magic_1__r
r
r
r�RefClassfsr�c@seZdZdZdZdZdZdS)zTestSupport.OtherClassN)r�r�r�r��
attribute3r��__magic_2__r
r
r
r�
OtherClasslsr�cCsBt�|j|j�}|�dh|�t�|j|j�}|�ddh|�dS)Nr�r�r�)r�detect_api_mismatchr�r�r)r�
missing_itemsr
r
r�test_detect_api_mismatchrs��z$TestSupport.test_detect_api_mismatchcCsTddddg}tj|j|j|d�}|�t�|�tj|j|j|d�}|�t�|�dS)Nr�r�r�Z
not_in_either)�ignore)rr�r�r�r�set)rr�r�r
r
r� test_detect_api_mismatch__ignore{s��z,TestSupport.test_detect_api_mismatch__ignorecCsZdh}dh}tj|t||d�ddh}dddh}tj|td	||d�|�ttj|t�dS)
NZtempdir�template)�extra�	blacklistZTextTestResultZinstallHandlerZ
load_testsZTestProgramZ
BaseTestSuite)zunittest.resultz
unittest.casezunittest.suitezunittest.loaderz
unittest.mainzunittest.runnerzunittest.signalszunittest.async_case)rZcheck__all__rFr	rr�)rr�r�r
r
r�test_check__all__�s �
�	zTestSupport.test_check__all__�waitpid�WNOHANGz need os.waitpid() and os.WNOHANGcCs�t��t��}|dkr"t�d�t��}t��d}tj}z�dt_t�	�}t��|krb|�
d�tj}z|t_t��W5|t_Xtjr�q�t�
d�qLd|}|�||���|�tj�W5|t_Xt��dS)NrgN@FZtimeoutg�������?z2Warning -- reap_children() reaped child process %s)rZ
reap_childrenr!rg�_exit�time�	monotonicZenvironment_altered�io�StringIOZfailr�
__stderr__�sleeprr�rK)r�pidZt0ZdeadlineZwas_alteredr��
old_stderrrvr
r
r�test_reap_children�s2

zTestSupport.test_reap_childrenNcCs�d|�d|�d�}tjf|d|f�}dd�tj��D�}tj|tjtjd|d�}|dkr\|}|�	|j
��t|��|�	|j
d	�dS)
Nzfrom test.support import z
; print(repr(z()))rhcSs i|]\}}|�d�s||�qS)ZPYTHON)rc)r\�key�valuer
r
r�
<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��procr
r
r�
check_options�s�zTestSupport.check_optionscCs�gdgdgdgdgdgdgdgdgd	gd
gdgdd
gddd
gddgddgddgddgddgddgfD](}|j|d��|�|d�W5QRXqd|�dddgddg�dS)Nz-Bz-sz-Sz-Ez-vz-bz-qz-Iz-bbz-vvvz-Wignorez-XZdevZfaulthandlerZ
importtimeZshowalloccountZshowrefcount�tracemallocz
tracemalloc=3��optsZargs_from_interpreter_flags�ZsubTestr��rr�r
r
r� test_args_from_interpreter_flags�s4��z,TestSupport.test_args_from_interpreter_flagsc
Cs@gdgdgdgfD](}|j|d��|�|d�W5QRXqdS)Nz-Oz-OOz-OOOOr�Z!optim_args_from_interpreter_flagsr�r�r
r
r�&test_optim_args_from_interpreter_flags�s�z2TestSupport.test_optim_args_from_interpreter_flagsc	Cs�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�|��W5QRXt�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�|��W5QRXdS)Nc@seZdZdd�Zdd�ZdS)z)TestSupport.test_match_test.<locals>.TestcSs
||_dSr��test_id)rr�r
r
r�__init__
sz2TestSupport.test_match_test.<locals>.Test.__init__cSs|jSrr�rr
r
r�idsz,TestSupport.test_match_test.<locals>.Test.idN)r�r�r�r�r�r
r
r
r�Testsr�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_testsrKZ
match_testr�r )rr�r�Z
test_chdirr
r
r�test_match_testsz
zTestSupport.test_match_testc	CsDt��}t�ttj�}zt��}W5t�|�X|�||d�dS)Nr^)rZfd_countr!r�__file__�O_RDONLYr@r)r�startr�Zmorer
r
r�
test_fd_counttszTestSupport.test_fd_countcCs@t��}tj}z|t_t�|�W5|t_X|�|��|�dSr)r�r�rr�rZ
print_warningrr�)rrvr�r�r�r
r
r�check_print_warning�szTestSupport.check_print_warningcCs|�dd�|�dd�dS)NrvzWarning -- msg
za
bzWarning -- a
Warning -- b
)r�rr
r
r�test_print_warning�s��zTestSupport.test_print_warning)N)7r�r�r�rrrr	�skiprrr%r1r<rCrDrErNrOrUrfZ
skipUnlessr�r!rjrorsrurwr}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
r
rrsh


		�
/
#ircCstg}tj|�dSr)rrZrun_unittest)Ztestsr
r
r�	test_main�sr��__main__)�
contextlibr�r8r�r!rSr=r-r�rrFrir�r	ZtestrZtest.supportrrZTestCaserr�r�r
r
r
r�<module>s2

Zerion Mini Shell 1.0