Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_support.cpython-39.opt-1.pyc

a

��g3e�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZddlmZejZGdd�dej�Zdd�Zed	kr�e��dS)
�N)�support)�
script_helper)�
socket_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�TestSupportcCs.ttj�}tjddd�|_tjddd�|_dS)Nztest.test_supportz.*used in test_support.*)Zlikez!.*You should NOT be seeing this.*)�len�warnings�filtersrZignore_deprecations_from�_warnings_helper_token�_test_support_token��clsZorig_filter_len�r
�-/usr/local/lib/python3.9/test/test_support.py�
setUpClasss
��zTestSupport.setUpClasscCsttj�}t�|j|j�dS�N)rrrrZclear_ignored_deprecationsr	r
rr
r
r�
tearDownClass#s
�zTestSupport.tearDownClasscCsbtjdd��0}t�t�dt�dd�|D�}Wd�n1sB0Y|�t|�d|�dS)z9Test support.ignore_deprecations_from() silences warningsT)�recordzYou should NOT be seeing this.cSsg|]}t|j��qSr
��str�message��.0�wr
r
r�
<listcomp>1�zDTestSupport.test_ignored_deprecations_are_silent.<locals>.<listcomp>Nr)r�catch_warnings�_warn_about_deprecation�warn�DeprecationWarning�assertEqualr)�selfZwarning_objs�messagesr
r
r�$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 r
r
r�test_import_module4s
zTestSupport.test_import_modulecCst�d�dS)Nr#)rZimport_fresh_moduler)r
r
r�test_import_fresh_module8sz$TestSupport.test_import_fresh_modulecCs.|�t�|d�|j�|�tjtj|d�dS)N�test_get_attributer$)rrZ
get_attributer,r&r'r(r)r
r
rr,;s�zTestSupport.test_get_attributezfailing buildbotscCs|�t��tj�dSr)rrZget_original_stdout�sys�stdoutr)r
r
r�test_get_original_stdout@sz$TestSupport.test_get_original_stdoutcCs2ddl}|�dtj�t�d�|�dtj�dS)Nr�sched)r0�assertInr-�modulesrZunload�assertNotIn)r r0r
r
r�test_unloadDs
zTestSupport.test_unloadcCsTttd��}Wd�n1s 0Yt�t�|�tj�t��t�t�dS)Nr)�open�TESTFNr�unlink�assertFalse�os�path�exists)r �fr
r
r�test_unlinkJs

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)rr6r9r:�join�mkdir�rmtreer8r;�	swap_attr�chmod�stat�S_IRUSR�S_IXUSR)r �dirpathZ
subdirpathr
r
r�test_rmtreeQs(



(

(

*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__)r6r5�printr-r:�insertr9�curdir�	importlib�invalidate_caches�
__import__r1r2rZforgetr3r7rB)r Zmod_filenamer<�modr
r
r�test_forgetis *

�
zTestSupport.test_forgetcCst�tjdf�}|��dS)Nr)�socket�
create_serverr�HOST�close�r �sr
r
r�	test_HOSTzszTestSupport.test_HOSTcCs$t��}t�tj|f�}|��dSr)rZfind_unused_portrUrVrWrX)r �portrZr
r
r�test_find_unused_port~sz!TestSupport.test_find_unused_portcCs&t��}t�|�|��|��dSr)rUrZ	bind_port�listenrXrYr
r
r�test_bind_port�s
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�mkdtempr9r:�realpathr@r8�isdirr�temp_dirr�
assertTruerB)r �
parent_dirr:�	temp_pathr
r
r�
test_temp_dir�s0zTestSupport.test_temp_dircCsPt���"}|�tj�|��Wd�n1s00Y|�tj�|��dS)zTest passing no path.N)rrdrer9r:rcr8)r rgr
r
r�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)rrd�	Exception)r:rgr
r
r�
call_temp_dir�szMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dirN)r`rar9r:rbrercr&�FileExistsError�shutilrB)r rlr:r
r
r�*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
rrr
r
rr�rzGTestSupport.test_temp_dir__existing_dir__quiet_true.<locals>.<listcomp>�rz5tests may fail, unable to create temporary directory �: )r`rar9r:rbr�check_warningsrdrrrercrnrBr�
startswith)r r:�recorderrgrrr
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

                    # 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)r
r
r�test_temp_dir__forked_child�sz'TestSupport.test_temp_dir__forked_childc	Cs�t��}t���V}t�|��,}|�||�|�t��|�Wd�n1sN0YWd�n1sl0Y|�t��|�dSr)r9�getcwdrrd�
change_cwdr)r �original_cwdrg�new_cwdr
r
r�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(0YdSrj)rr~rk)r:r�r
r
r�call_change_cwd�szFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwd�does_not_existN)	r9r}rrdr:r@r&�FileNotFoundErrorr)r rr�rfZnon_existent_dirr
r
r�!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.r�TrpNcSsg|]}t|j��qSr
rrr
r
rrrzMTestSupport.test_change_cwd__non_existent_dir__quiet_true.<locals>.<listcomp>rrr�Btests may fail, unable to change the current working directory to rs)
r9r}rrdr:r@rtr~rrrreru)r rrfZbad_dirrvr�rrr
r
r�-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:rqNcSsg|]}t|j��qSr
rrr
r
rrrz>TestSupport.test_change_cwd__chdir_warning.<locals>.<listcomp>rrrr�rs)	r6rrtr~rrrreru)r r:rvr!�msgr
r
r�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)
r9r}r�temp_cwdr6rr:�basenamer8r;)r �herer
r
r�
test_temp_cwds
6zTestSupport.test_temp_cwdcCsvt��}tjdd��>}|�||�|�tj�|��|�t��|�Wd�n1sX0Y|�t��|�dS)z Test passing None to temp_cwd().Nr�)	r9r}rr�ZassertNotEqualrer:rcr)r rr�r
r
r�test_temp_cwd__name_none&s.z$TestSupport.test_temp_cwd__name_nonecCs|�t�dddd��d�dS)N��rr)r�r�rrz{1: 1, 2: 2, 3: 3})rrZsortdictr)r
r
r�
test_sortdict/szTestSupport.test_sortdictcCsTt��}|�t��}t�|d�Wd�n1s40Y|�|jjtj	�dS)Nsfoo)
rZmake_bad_fdr&�OSErrorr9�writer�	exception�errno�EBADF)r �fd�cmr
r
r�test_make_bad_fd2s*zTestSupport.test_make_bad_fdcCsLtj|dddd�|�t��t�|d�Wd�n1s>0YdS)Nz	def classrr�)�lineno�offsetzx=1)rZcheck_syntax_errorr&�AssertionErrorr)r
r
r�test_check_syntax_error8sz#TestSupport.test_check_syntax_errorcCs@ddl}t�d��|�d�Wd�n1s20YdS)NrZasyncore)rPrZCleanImportr%)r rPr
r
r�test_CleanImport=szTestSupport.test_CleanImportcCsht�dd��,|�dtj�|�dtj�Wd�n1s>0Y|�dtj�|�dtj�dS)Nr$Zbar)rZ
DirsOnSysPathr1r-r:r3r)r
r
r�test_DirsOnSysPathBs
,zTestSupport.test_DirsOnSysPathcCsDt���}td�Wd�n1s&0Y|�|��d�dS)N�hello�hello
)rZcaptured_stdoutrMr�getvalue)r r.r
r
r�test_captured_stdoutIs
&z TestSupport.test_captured_stdoutcCsJt���}tdtjd�Wd�n1s,0Y|�|��d�dS)Nr�rJr�)rZcaptured_stderrrMr-�stderrrr�)r r�r
r
r�test_captured_stderrNs
,z TestSupport.test_captured_stderrcCsRt���*}|�d�|�d�t�}Wd�n1s80Y|�|d�dS)Nr�rr�)rZcaptured_stdinr��seek�inputr)r �stdinZcapturedr
r
r�test_captured_stdinSs



$zTestSupport.test_captured_stdincCst��dSr)r�
gc_collectr)r
r
r�test_gc_collect[szTestSupport.test_gc_collectcCs|�t��t�dSr)ZassertIsInstancerZpython_is_optimized�boolr)r
r
r�test_python_is_optimized^sz$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__r
r
r
r�Objbsr�rr�xr��y)r�rrCrr��assertIsNoner8�hasattr)r r��objr�r�r
r
r�test_swap_attras*("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�rrr�r�)rZ	swap_itemrr�r3)r �Dr�r�r
r
r�test_swap_itemrs*($zTestSupport.test_swap_itemc@seZdZdZdZdZdZdS)zTestSupport.RefClassN)r�r�r��
attribute1�
attribute2Z_hidden_attribute1�__magic_1__r
r
r
r�RefClass�sr�c@seZdZdZdZdZdZdS)zTestSupport.OtherClassN)r�r�r�r��
attribute3r��__magic_2__r
r
r
r�
OtherClass�sr�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_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�r
r
r� 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�	blacklistZTextTestResultZinstallHandler>ZTestProgramZ
load_testsZ
BaseTestSuite)zunittest.resultz
unittest.casezunittest.suitezunittest.loaderz
unittest.mainzunittest.runnerzunittest.signalszunittest.async_case)rZcheck__all__r`r'r&r�)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��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)NrF�timeoutg�������?z2Warning -- reap_children() reaped child process %s)r�
reap_childrenr9rx�_exit�time�	monotonicZ
SHORT_TIMEOUTZenvironment_altered�io�StringIOZfailr-�
__stderr__�sleepr1r�re)r �pid�t0�deadlineZwas_alteredr��
old_stderrr�r
r
r�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()))rycSs i|]\}}|�d�s||�qS)ZPYTHON)ru)r�key�valuer
r
r�
<dictcomp>�s
�z-TestSupport.check_options.<locals>.<dictcomp>T)r.r��universal_newlines�envr)r-�
executabler9�environ�items�
subprocess�run�PIPE�DEVNULLrr.�rstrip�repr�
returncode)r �args�func�expected�code�cmdr��procr
r
r�
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��faulthandler�
importtime�showrefcount�tracemallocz
tracemalloc=3��optsZargs_from_interpreter_flags)r�r�r��ZsubTestr��r rr
r
r� 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_flagsrrr
r
r�&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�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 rr
r
r�__init__&sz2TestSupport.test_match_test.<locals>.Test.__init__cSs|jSrrr)r
r
r�id)sz,TestSupport.test_match_test.<locals>.Test.idN)r�r�r�rrr
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)�ignore_patterns)rrCZset_match_testsreZ
match_testrr8)r r	r
Z
test_chdirr
r
r�test_match_test$sz
0zTestSupport.test_match_testc	CsNt��}t�ttj�}zt��}Wt�|�nt�|�0|�||d�dS)Nrr)rZfd_countr9r5�__file__�O_RDONLYrXr)r �startr�Zmorer
r
r�
test_fd_count�s
zTestSupport.test_fd_countcCsFt��}tj}z|t_t�|�W|t_n|t_0|�|��|�dSr)r�r�r-r�rZ
print_warningrr�)r r�r�r�r�r
r
r�check_print_warning�szTestSupport.check_print_warningcCs|�dd�|�dd�dS)Nr�zWarning -- msg
za
bzWarning -- a
Warning -- b
)rr)r
r
r�test_print_warning�s��zTestSupport.test_print_warning)N);r�r�r��classmethodrrr"r*r+r,r'�skipr/r4r=rIrTr[r]r_rhrirorwZ
skipUnlessr�r9r|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�rrrrrrr
r
r
rrsr





		�
/
"ircCstjdtdd�dS)Nz�This is used in test_support test to ensure support.ignore_deprecations_from() works as expected. You should not be seeing this.r)�
stacklevel)rrrr
r
r
rr�s
�r�__main__)r�rPr�r9rnrUrEr�r-r`rzr�r'r�testrZtest.supportrrr6ZTestCaserrr��mainr
r
r
r�<module>s42

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists