%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core18/current/usr/lib/python3.6/test/__pycache__/
Upload File :
Create Path :
Current File : //snap/core18/current/usr/lib/python3.6/test/__pycache__/test_support.cpython-36.pyc

3

/�$h�L�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZejZGdd�de
j�Zdd�Zedkr�e�dS)	�N)�support)�
script_helperc@s�eZdZdd�Zdd�Zdd�Zejd�dd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zejeed �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.d]dSdT�Z/dUdV�Z0dWdX�Z1dYdZ�Z2d[d\�Z3dRS)^�TestSupportcCs tjd�|jtjtjd�dS)N�ftplib�foo)r�
import_module�assertRaises�unittest�SkipTest)�self�r�'/usr/lib/python3.6/test/test_support.py�test_import_modules
zTestSupport.test_import_modulecCstjd�dS)Nr)rZimport_fresh_module)rrrr
�test_import_fresh_modulesz$TestSupport.test_import_fresh_modulecCs.|jtj|d�|j�|jtjtj|d�dS)N�test_get_attributer)�assertEqualrZ
get_attributerrr	r
)rrrr
rszTestSupport.test_get_attributezfailing buildbotscCs|jtj�tj�dS)N)rrZget_original_stdout�sys�stdout)rrrr
�test_get_original_stdout sz$TestSupport.test_get_original_stdoutcCs2ddl}|jdtj�tjd�|jdtj�dS)Nr�sched)r�assertInr�modulesrZunload�assertNotIn)rrrrr
�test_unload$s
zTestSupport.test_unloadc
Cs@ttd��}WdQRXtjt�|jtjjt��tjt�dS)N�w)�open�TESTFNr�unlink�assertFalse�os�path�exists)r�frrr
�test_unlink*s


zTestSupport.test_unlinkcCs$tjd}tjj|d�}tj|�tj|�tj|�|jtjj|��tj	tdd��tj|�WdQRXtj|�tj|�tj
|tjtj
B�tj	tdd��tj|�WdQRX|jtjj|��tj|�tj|�tj
|d�tj	tdd��tj|�WdQRX|jtjj|��dS)N�dZsubdir�verboser)rrrr �join�mkdir�rmtreerr!�	swap_attr�chmod�stat�S_IRUSR�S_IXUSR)r�dirpathZ
subdirpathrrr
�test_rmtree1s(







zTestSupport.test_rmtreecCs�td}t|d��}td|d�WdQRXtjjdtj�tj	�z2t
t�}|jttj�t
jt�|jttj�Wdtjd=t
j|�t
jd�XdS)Nz.pyrzfoo = 1)�filer�__pycache__)rr�printrr �insertr�curdir�	importlib�invalidate_caches�
__import__rrrZforgetrrr()rZmod_filenamer"�modrrr
�test_forgetIs

zTestSupport.test_forgetcCs$tj�}|jtjdf�|j�dS)Nr)�socket�bindr�HOST�close)r�srrr
�	test_HOSTZszTestSupport.test_HOSTcCs,tj�}tj�}|jtj|f�|j�dS)N)rZfind_unused_portr:r;r<r=)rZportr>rrr
�test_find_unused_port_sz!TestSupport.test_find_unused_portcCs&tj�}tj|�|j�|j�dS)N)r:rZ	bind_portZlistenr=)rr>rrr
�test_bind_portes
zTestSupport.test_bind_portcCs�tj�}tjj|�}zjtjj|d�}|jtjj|��tj	|��$}|j
||�|jtjj|��WdQRX|jtjj|��Wdtj|�XdS)z8Test that temp_dir() creates and destroys its directory.ZtempN)
�tempfile�mkdtemprr �realpathr&r�isdirr�temp_dirr�
assertTruer()r�
parent_dirr �	temp_pathrrr
�
test_temp_dirmszTestSupport.test_temp_dirc
Cs<tj��}|jtjj|��WdQRX|jtjj|��dS)zTest passing no path.N)rrFrGrr rEr)rrIrrr
�test_temp_dir__path_none|s
z$TestSupport.test_temp_dir__path_nonecCsddd�}tj�}tjj|�}z6|jtjj|��|jt||�|jtjj|��Wdt	j
|�XdS)z-Test passing a directory that already exists.c	Ss"tj|��}td��WdQRXdS)Nzshould not get here)rrF�	Exception)r rIrrr
�
call_temp_dir�szMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dirN)rBrCrr rDrGrEr�FileExistsError�shutilr()rrMr rrr
�*test_temp_dir__existing_dir__quiet_default�sz6TestSupport.test_temp_dir__existing_dir__quiet_defaultcCs�tj�}tjj|�}z`tj��<}tj|dd��}|j||�WdQRXdd�|j	D�}WdQRX|j
tjj|��Wdtj
|�Xd|g}|j||�dS)z=Test passing a directory that already exists with quiet=True.T)�quietNcSsg|]}t|j��qSr)�str�message)�.0rrrr
�
<listcomp>�szGTestSupport.test_temp_dir__existing_dir__quiet_true.<locals>.<listcomp>z+tests may fail, unable to create temp dir: )rBrCrr rDr�check_warningsrFr�warningsrGrErOr()rr �recorderrIrW�expectedrrr
�'test_temp_dir__existing_dir__quiet_true�s

z3TestSupport.test_temp_dir__existing_dir__quiet_true�forkztest requires os.forkcCstjdtjd��dS)z?Test that a forked child process does not remove the directory.z-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�textwrapZdedent)rrrr
�test_temp_dir__forked_child�s
z'TestSupport.test_temp_dir__forked_childcCsbtj�}tj��8}tj|��"}|j||�|jtj�|�WdQRXWdQRX|jtj�|�dS)N)r�getcwdrrF�
change_cwdr)r�original_cwdrI�new_cwdrrr
�test_change_cwd�s
$zTestSupport.test_change_cwdcCsTtj�}dd�}tj��"}tjj|d�}|jt||�WdQRX|jtj�|�dS)z&Test passing a non-existent directory.c	Ss"tj|��}td��WdQRXdS)Nzshould not get here)rr_rL)r rarrr
�call_change_cwd�szFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwd�does_not_existN)	rr^rrFr r&r�FileNotFoundErrorr)rr`rcrHZnon_existent_dirrrr
�!test_change_cwd__non_existent_dir�s
z-TestSupport.test_change_cwd__non_existent_dircCs�tj�}tj��n}tjj|d�}tj��L}tj|dd��"}|j||�|jtj�|�WdQRXdd�|j	D�}WdQRXWdQRXd|g}|j||�dS)z6Test passing a non-existent directory with quiet=True.rdT)rQNcSsg|]}t|j��qSr)rRrS)rTrrrr
rU�szMTestSupport.test_change_cwd__non_existent_dir__quiet_true.<locals>.<listcomp>z)tests may fail, unable to change CWD to: )
rr^rrFr r&rVr_rrW)rr`rHZbad_dirrXrarWrYrrr
�-test_change_cwd__non_existent_dir__quiet_true�s

$
z9TestSupport.test_change_cwd__non_existent_dir__quiet_truecCs\td}tj��0}tj|dd��WdQRXdd�|jD�}WdQRX|j|d|g�dS)z0Check the warning message when os.chdir() fails.Z_does_not_existT)r rQNcSsg|]}t|j��qSr)rRrS)rTrrrr
rU�sz>TestSupport.test_change_cwd__chdir_warning.<locals>.<listcomp>z)tests may fail, unable to change CWD to: )rrrVr_rWr)rr rXZmessagesrrr
�test_change_cwd__chdir_warning�s

z*TestSupport.test_change_cwd__chdir_warningc
Cs^tj�}tjtd��|jtjjtj��t�WdQRX|jtjj	t��|jtj�|�dS)N)�name)
rr^r�temp_cwdrrr �basenamerr!)r�hererrr
�
test_temp_cwd�s
"zTestSupport.test_temp_cwdc
Csbtj�}tjdd��4}|j||�|jtjj|��|jtj�|�WdQRX|jtj�|�dS)z Test passing None to temp_cwd().N)ri)	rr^rrjZassertNotEqualrGr rEr)rr`rarrr
�test_temp_cwd__name_none�sz$TestSupport.test_temp_cwd__name_nonecCs|jtjdddd��d�dS)N���)rorprqz{1: 1, 2: 2, 3: 3})rrZsortdict)rrrr
�
test_sortdictszTestSupport.test_sortdictc
Cs@tj�}|jt��}tj|d�WdQRX|j|jjtj	�dS)Nsfoo)
rZmake_bad_fdr�OSErrorr�writerZ	exception�errnoZEBADF)r�fd�cmrrr
�test_make_bad_fd
szTestSupport.test_make_bad_fdc
Cs8tj|dddd�|jt��tj|d�WdQRXdS)Nz	def classrq�	)�lineno�offsetzx=1)rZcheck_syntax_errorr�AssertionError)rrrr
�test_check_syntax_errorsz#TestSupport.test_check_syntax_errorc	Cs,ddl}tjd��|jd�WdQRXdS)NrZasyncore)r5rZCleanImportr)rr5rrr
�test_CleanImportszTestSupport.test_CleanImportc
CsTtjdd��"|jdtj�|jdtj�WdQRX|jdtj�|jdtj�dS)NrZbar)rZ
DirsOnSysPathrrr r)rrrr
�test_DirsOnSysPaths
zTestSupport.test_DirsOnSysPathc
Cs0tj��}td�WdQRX|j|j�d�dS)N�hellozhello
)rZcaptured_stdoutr2r�getvalue)rrrrr
�test_captured_stdout!s
z TestSupport.test_captured_stdoutcCs6tj��}tdtjd�WdQRX|j|j�d�dS)Nr�)r0zhello
)rZcaptured_stderrr2r�stderrrr�)rr�rrr
�test_captured_stderr&s
z TestSupport.test_captured_stderrc
Cs>tj�� }|jd�|jd�t�}WdQRX|j|d�dS)Nzhello
rr�)rZcaptured_stdinrt�seek�inputr)r�stdinZcapturedrrr
�test_captured_stdin+s



zTestSupport.test_captured_stdincCstj�dS)N)rZ
gc_collect)rrrr
�test_gc_collect3szTestSupport.test_gc_collectcCs|jtj�t�dS)N)ZassertIsInstancerZpython_is_optimized�bool)rrrr
�test_python_is_optimized6sz$TestSupport.test_python_is_optimizedcCs�Gdd�d�}|�}d|_tj|dd�� }|j|jd�|j|d�WdQRX|j|jd�tj|dd��}|j|jd�|j|�WdQRX|jt|d��tj|dd��
|`WdQRX|jt|d��dS)Nc@seZdZdS)z'TestSupport.test_swap_attr.<locals>.ObjN)�__name__�
__module__�__qualname__rrrr
�Obj:sr�rq�x��y)r�rr)rr��assertIsNoner�hasattr)rr��objr�r�rrr
�test_swap_attr9szTestSupport.test_swap_attrcCs�ddi}tj|dd��"}|j|dd�|j|d�WdQRX|j|dd�tj|dd�� }|j|dd�|j|�WdQRX|jd|�tj|dd��|d=WdQRX|jd|�dS)Nr�rqr�r�)rZ	swap_itemrr�r)r�Dr�r�rrr
�test_swap_itemJszTestSupport.test_swap_itemc@seZdZdZdZdZdZdS)zTestSupport.RefClassN)r�r�r��
attribute1�
attribute2Z_hidden_attribute1�__magic_1__rrrr
�RefClassXsr�c@seZdZdZdZdZdZdS)zTestSupport.OtherClassN)r�r�r�r��
attribute3r��__magic_2__rrrr
�
OtherClass^sr�cCsBtj|j|j�}|jdh|�tj|j|j�}|jddh|�dS)Nr�r�r�)r�detect_api_mismatchr�r�r)r�
missing_itemsrrr
�test_detect_api_mismatchdsz$TestSupport.test_detect_api_mismatchcCsTddddg}tj|j|j|d�}|jt�|�tj|j|j|d�}|jt�|�dS)Nr�r�r�Z
not_in_either)�ignore)rr�r�r�r�set)rr�r�rrr
� test_detect_api_mismatch__ignoremsz,TestSupport.test_detect_api_mismatch__ignorec
CsZdh}dh}tj|t||d�ddh}dddh}tj|td||d�|jttj|t�dS)NZtempdir�template)�extra�	blacklistZTextTestResultZinstallHandlerZ
load_testsZTestProgramZ
BaseTestSuite�unittest.result�
unittest.case�unittest.suite�unittest.loader�
unittest.main�unittest.runner�unittest.signals)r�r�r�r�r�r�r�)rZcheck__all__rBr	rr|)rr�r�rrr
�test_check__all__xs"
zTestSupport.test_check__all__NcCs�d|�d|�d�}tjf|d|f�}dd�tjj�D�}tj|tjtjd|d�}|dkr\|}|j	|j
j�t|��|j	|j
d	�dS)
Nzfrom test.support import z
; print(repr(z()))z-ccSs i|]\}}|jd�s||�qS)ZPYTHON)�
startswith)rT�key�valuerrr
�
<dictcomp>�sz-TestSupport.check_options.<locals>.<dictcomp>T)rr�Zuniversal_newlines�envr)r�
executabler�environ�items�
subprocessZrun�PIPEZDEVNULLrr�rstrip�repr�
returncode)r�args�funcrY�code�cmdr��procrrr
�
check_options�szTestSupport.check_optionscCs�x|gdgdgdgdgdgdgdgdgd	gd
gdgdd
gddgddgddgddgfD](}|j|d��|j|d�WdQRXqRW|jdddgddg�dS)Nz-Bz-sz-Sz-Ez-vz-bz-qz-Iz-bbz-vvvz-Wignorez-XZfaulthandlerZshowalloccountZshowrefcount�tracemallocz
tracemalloc=3)�optsZargs_from_interpreter_flags)�subTestr�)rr�rrr
� test_args_from_interpreter_flags�s,z,TestSupport.test_args_from_interpreter_flagscCsDx>gdgdgdgfD](}|j|d��|j|d�WdQRXqWdS)Nz-Oz-OOz-OOOO)r�Z!optim_args_from_interpreter_flags)r�r�)rr�rrr
�&test_optim_args_from_interpreter_flags�sz2TestSupport.test_optim_args_from_interpreter_flagsc
Cs�Gdd�d�}|d�}|d�}tjtdd����tjg�|jtj|��|jtj|��tjd�|jtj|��|jtj|��tj|j�g�|jtj|��|jtj|��tjdg�|jtj|��|jtj|��tjdg�|jtj|��|jtj|��tjdg�|jtj|��tjd	g�|jtj|��tjd
g�|jtj|��|jtj|��tj|j�|j�g�|jtj|��|jtj|��tjddg�|jtj|��|jtj|��WdQRXdS)
Nc@seZdZdd�Zdd�ZdS)z)TestSupport.test_match_test.<locals>.TestcSs
||_dS)N)�test_id)rr�rrr
�__init__�sz2TestSupport.test_match_test.<locals>.Test.__init__cSs|jS)N)r�)rrrr
�id�sz,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)rr)Zset_match_testsrGZ
match_testr�r)rr�r�Z
test_chdirrrr
�test_match_test�s@

zTestSupport.test_match_testcCsDtj�}tjttj�}ztj�}Wdtj|�X|j||d�dS)Nrq)rZfd_countrr�__file__�O_RDONLYr=r)r�startrvZmorerrr
�
test_fd_countszTestSupport.test_fd_count)N)4r�r�r�rrrr	�skiprrr#r/r9r?r@rArJrKrPrZZ
skipUnlessr�rr]rbrfrgrhrmrnrrrxr}r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rsX
		
 9rcCstg}tj|�dS)N)rrZrun_unittest)Ztestsrrr
�	test_main)sr��__main__)rur5rrOr:r+r�rrBr\r	ZtestrZtest.supportrrZTestCaserr�r�rrrr
�<module>s*

Zerion Mini Shell 1.0