CasperSecurity

Current Path : /usr/lib/python3.10/test/__pycache__/
Upload File :
Current File : //usr/lib/python3.10/test/__pycache__/test_support.cpython-310.pyc

o

`�wiVe�@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.*)�likeztest.test_supportz!.*You should NOT be seeing this.*�)�len�warnings�filtersr�ignore_deprecations_from�_warnings_helper_token�_test_support_token��cls�orig_filter_len�r�(/usr/lib/python3.10/test/test_support.py�
setUpClasss
��zTestSupport.setUpClasscCs4ttj�}t�|j|j�ttj�|dksJ�dS)Nr
)rrr
r�clear_ignored_deprecationsrrrrrr�
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_warningsr�_warn_about_deprecation�warn�DeprecationWarning�assertEqualr)�self�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,)r�import_fresh_moduler2rrr�test_import_fresh_module<sz$TestSupport.test_import_fresh_modulecCs.|�t�|d�|j�|�tjtj|d�dS)N�test_get_attributer-)r'r�
get_attributer6r/r0r1r2rrrr6?s�zTestSupport.test_get_attributezfailing buildbotscCs|�t��tj�dS�N)r'r�get_original_stdout�sys�stdoutr2rrr�test_get_original_stdoutDsz$TestSupport.test_get_original_stdoutcCs2ddl}|�dtj�t�d�|�dtj�dS)Nr�sched)r=�assertInr:�modulesr�unload�assertNotIn)r(r=rrr�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�d�subdir�verboser)rrGrJrK�join�mkdir�rmtreerIrLr�	swap_attr�chmod�stat�S_IRUSR�S_IXUSR)r(�dirpath�
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.pyr rCrDzfoo = 1��filer�__pycache__)rGrF�printr:rK�insertrJ�curdir�	importlib�invalidate_caches�
__import__r>r?r�forgetrArrHrT)r(�mod_filenamerM�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�}|��dSr8)r�find_unused_portrjrkrlrm)r(�portrorrr�test_find_unused_port�sz!TestSupport.test_find_unused_portcCs&t��}t�|�|��|��dSr8)rjr�	bind_port�listenrmrnrrr�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.�tempN)
�tempfile�mkdtemprJrK�realpathrRrI�isdirr�temp_dirr'�
assertTruerT)r(�
parent_dirrK�	temp_pathrrr�
test_temp_dir�s�zTestSupport.test_temp_dircCsPt���}|�tj�|��Wd�n1swY|�tj�|��dS)zTest passing no path.N)rr|r}rJrKr{rI)r(rrrr�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)rr|�	Exception)rKrrrr�
call_temp_dir���zMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dirN)rxryrJrKrzr}r{r/�FileExistsError�shutilrT)r(r�rKrrr�*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!�r"zGTestSupport.test_temp_dir__existing_dir__quiet_true.<locals>.<listcomp>�rz5tests may fail, unable to create temporary directory �: )rxryrJrKrzr�check_warningsrr|r'rr}r{r�rTr�
startswith)r(rK�recorderrrr%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)r�assert_python_ok�textwrap�dedentr2rrr�test_temp_dir__forked_child�sz'TestSupport.test_temp_dir__forked_childc	Cs�t��}t���+}t�|��}|�||�|�t��|�Wd�n1s'wYWd�n1s6wY|�t��|�dSr8)rJ�getcwdrr|�
change_cwdr')r(�original_cwdr�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.cSr�r�)rr�r�)rKr�rrr�call_change_cwd�r�zFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwd�does_not_existN)	rJr�rr|rKrRr/�FileNotFoundErrorr')r(r�r�r~�non_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�Tr�NcSrrrrrrrr!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 r�)rJr�rr|rKrRrr�r�r'rrr}r�)r(r�r~�bad_dirr�r�rr%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.�_does_not_existT)rKr�NcSrrrrrrrr!r"z>TestSupport.test_change_cwd__chdir_warning.<locals>.<listcomp>r�rr�r�)
rGrr�rr�rr'rr}r�)r(rKr�r*�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)
rJr�r�temp_cwdrGr'rK�basenamerIrL)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�)	rJr�rr��assertNotEqualr}rKr{r')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'r�sortdictr2rrr�
test_sortdict4szTestSupport.test_sortdictcCsTt��}|�t��}t�|d�Wd�n1swY|�|jjtj	�dS)Nsfoo)
r�make_bad_fdr/�OSErrorrJ�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)r�check_syntax_errorr/�AssertionErrorr2rrr�test_check_syntax_error=s"�z#TestSupport.test_check_syntax_errorcCsBddl}t�d��|�d�Wd�dS1swYdS)Nr�pprint)rcr�CleanImportr.)r(rcrrr�test_CleanImportBs"�zTestSupport.test_CleanImportcCsht�dd��|�dtj�|�dtj�Wd�n1swY|�dtj�|�dtj�dS)Nr-�bar)r�
DirsOnSysPathr>r:rKrAr2rrr�test_DirsOnSysPathGs�zTestSupport.test_DirsOnSysPathcCsDt���}td�Wd�n1swY|�|��d�dS)N�hello�hello
)r�captured_stdoutr`r'�getvalue)r(r;rrr�test_captured_stdoutNs

�z TestSupport.test_captured_stdoutcCsJt���}tdtjd�Wd�n1swY|�|��d�dS)Nr�r]r�)r�captured_stderrr`r:�stderrr'r�)r(r�rrr�test_captured_stderrSs
�z TestSupport.test_captured_stderrcCsRt���}|�d�|�d�t�}Wd�n1swY|�|d�dS)Nr�rr�)r�captured_stdinr��seek�inputr')r(�stdin�capturedrrr�test_captured_stdinXs


�zTestSupport.test_captured_stdincCst��dSr8)r�
gc_collectr2rrr�test_gc_collect`szTestSupport.test_gc_collectcCs|�t��t�dSr8)�assertIsInstancer�python_is_optimized�boolr2rrr�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�rrUr'r��assertIsNonerI�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�)r�	swap_itemr'r�rA)r(�Dr�r�rrr�test_swap_itemws���zTestSupport.test_swap_itemc@�eZdZdZdZdZdZdS)zTestSupport.RefClassN)r�r�r��
attribute1�
attribute2�_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��
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_exported�TextTestResult�installHandler>�
load_tests�TestProgram�
BaseTestSuite)zunittest.resultz
unittest.casezunittest.suitezunittest.loaderz
unittest.mainzunittest.runnerzunittest.signalszunittest.async_case)r�check__all__rxr0r/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_
wtjrKnt�d�q(d|}|�||���|�tj�W|t_n|t_wt��dS)NrFT�timeoutg�������?z2Warning -- reap_children() reaped child process %s)r�
reap_childrenrJr��_exit�time�	monotonic�
SHORT_TIMEOUT�environment_altered�io�StringIO�failr:�
__stderr__�sleepr>r�r})r(�pid�t0�deadline�was_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)�PYTHON)r�)r�key�valuerrr�
<dictcomp>�s�z-TestSupport.check_options.<locals>.<dictcomp>T)r;r��universal_newlines�envr)r:�
executablerJ�environ�items�
subprocess�run�PIPE�DEVNULLr'r;�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)r3r4r5�faulthandler�
importtime�showrefcount�tracemallocz
tracemalloc=3��opts�args_from_interpreter_flags)r2r1r0��subTestr/�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:�!optim_args_from_interpreter_flagsr=r?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
||_dSr8��test_id)r(rDrrr�__init__+s
z2TestSupport.test_match_test.<locals>.Test.__init__cSs|jSr8rCr2rrr�id.sz,TestSupport.test_match_test.<locals>.Test.idN)r�r�r�rErFrrrr�Test*srGz"test.test_os.FileTests.test_accessz'test.test_os.Win32ErrorTests.test_chdir�_match_test_func�test_osztest_*�	filetests�	FileTestsz*test_os.*.test_*�test_access�	DONTMATCH)�ignore_patterns)rrU�set_match_testsr}�
match_testrFrI)r(rGrL�
test_chdirrrr�test_match_test)s~
�/$�zTestSupport.test_match_testc	CsNt��}t�ttj�}zt��}Wt�|�nt�|�w|�||d�dS)Nr�)r�fd_countrJrF�__file__�O_RDONLYrmr')r(�startr��morerrr�
test_fd_count�s
zTestSupport.test_fd_countcCsFt��}tj}z
|t_t�|�W|t_n|t_w|�|��|�dSr8)rrr:rr�
print_warningr'r�)r(r�r+r�rrrr�check_print_warning�szTestSupport.check_print_warningcCs|�dd�|�dd�dS)Nr�zWarning -- msg
za
bzWarning -- a
Warning -- b
)rZr2rrr�test_print_warning�s��zTestSupport.test_print_warningr8);r�r�r��classmethodrrr+r3r5r6r0�skipr<rBrNr\rirprsrvr�r�r�r��
skipUnlessr�rJr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr/r@rBrRrXrZr[rrrrrst





		�

/"ir�__main__)r�rcrrJr�rjrWr"r:rxr�r
r0r�testr�test.supportrrrrrrG�TestCaserr��mainrrrr�<module>s<3�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY