403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_site.cpython-36.pyc
3

�w2_>e�@s*dZddlZddlZddlmZddlmZmZmZmZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZddlmZejjr�ejd��ddlZdadd	�Zd
d�ZGdd
�d
ej�ZGdd�de�Z Gdd�dej�Z!Gdd�dej�Z"e#dk�r&ej$�dS)zTests for 'site'.

Tests assume the initial paths in sys.path once the interpreter has begun
executing have not been removed.

�N)�support)�captured_stderr�TESTFN�EnvironmentVarGuard�
change_cwd)�mock)�copyzPython was invoked with -ScCs|tjdd�atjrxtjjtj�rxytjtj�tj	tj�Wn6t
k
rv}ztjdtj|f��WYdd}~XnXdS)Nz-unable to create user site directory (%r): %s)
�sys�path�OLD_SYS_PATH�site�ENABLE_USER_SITE�os�isdir�	USER_SITE�makedirs�
addsitedir�PermissionError�unittest�SkipTest)�exc�r�3/opt/alt/python36/lib64/python3.6/test/test_site.py�setUpModule%srcCsttjdd�<dS)N)rr	r
rrrr�tearDownModule4src@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	de
fdd�Zdd�Zdd�Z
dd�Zdd�Zejejd�dd��Zdd�Zdd�Zd d!�Zd"d#�Zd$S)%�HelperFunctionsTestsz Tests for helper functions.
    cCs@tjdd�|_tj|_tj|_tj|_	t
j|_t
t
j�|_dS)zSave a copy of sys.pathN)r	r
�sys_pathr�	USER_BASE�old_baser�old_site�PREFIXES�old_prefixes�	sysconfig�_CONFIG_VARS�
original_varsr�old_vars)�selfrrr�setUp<szHelperFunctionsTests.setUpcCsL|jtjdd�<|jt_|jt_|jt_	|j
t_tjj
�tjj|j�dS)zRestore sys.pathN)rr	r
rrrrrr!r r$r"r#�clear�updater%)r&rrr�tearDownEs
zHelperFunctionsTests.tearDowncCshd}tjj|�}tj|�\}}|jtjj|�|�|tjj|�krP|j||�n|jtjj|�|�dS)N�	Beginning�End)r+r,)rr
�joinr�makepath�assertEqual�abspath�normcase)r&�
path_partsZoriginal_dirZabs_dirZnorm_dirrrr�
test_makepathOsz"HelperFunctionsTests.test_makepathcCs<tj�}x.dd�tjD�D]}|j||d||f�qWdS)NcSs*g|]"}|rtjj|�rtj|�d�qS)�)rr
�existsrr.)�.0r
rrr�
<listcomp>^sz;HelperFunctionsTests.test_init_pathinfo.<locals>.<listcomp>zB%s from sys.path not found in set returned by _init_pathinfo(): %s)r�_init_pathinfor	r
�assertIn)r&Zdir_set�entryrrr�test_init_pathinfo\s
z'HelperFunctionsTests.test_init_pathinfocCsJ|j|jtjd|j�|jtj|j�dtj�|jt	jj
|j��dS)z>Contain common code for testing results of reading a .pth filez%s not in sys.modulesrN)r9�importedr	�modulesrr.�
good_dir_pathr
�assertFalserr5�bad_dir_path)r&�pth_filerrr�pth_file_testsdsz#HelperFunctionsTests.pth_file_testsc
CsLt�}|jdd�z*|j�tj|j|jt��|j|�Wd|j�XdS)NT)�prep)	�PthFile�cleanup�creater�
addpackage�base_dir�filename�setrB)r&rArrr�test_addpackageksz$HelperFunctionsTests.test_addpackage�.cs\tjj|�}|d}tjj||��t�ddd�}|j�fdd��|j|�|j�||fS)Nz.pth�wzutf-8)�encodingcs
tj��S)N)r�remover)�pth_fnrr�<lambda>�sz/HelperFunctionsTests.make_pth.<locals>.<lambda>)rr
r0r-�openZ
addCleanup�write�close)r&�contents�pth_dirZpth_nameZpth_basenamerAr)rPr�make_pthzs
zHelperFunctionsTests.make_pthc
Cs�|jd�\}}t��}tj||t��WdQRX|j|j�d�|j|j�tjt	j
j||���|j|j�d�|j|j�d�|j|j�d�dS)Nzimport bad)syntax
zline 1�	Tracebackzimport bad\)syntax�SyntaxError)rWrrrGrJ�assertRegex�getvalue�re�escaperr
r-)r&rVrP�err_outrrr�!test_addpackage_import_bad_syntax�s
z6HelperFunctionsTests.test_addpackage_import_bad_syntaxc
Cs�|jd�\}}t��}tj||t��WdQRX|j|j�d�|j|j�tjt	j
j||���|j|j�d�|j|j�d�dS)Nzrandompath
import nosuchmodule
zline 2rX�ModuleNotFoundError)rWrrrGrJrZr[r\r]rr
r-)r&rVrPr^rrr�test_addpackage_import_bad_exec�s
z4HelperFunctionsTests.test_addpackage_import_bad_execc
Cs�|jd�\}}t��}tj||t��WdQRX|j|j�d�|j|j�tjt	j
j||���|j|j�d�|j|j�d�dS)Nzabcdef
zline 1rX�
ValueError)rWrrrGrJrZr[r\r]rr
r-)r&rVrPr^rrr�#test_addpackage_import_bad_pth_file�s
z8HelperFunctionsTests.test_addpackage_import_bad_pth_filec
CsHt�}|jdd�z&|j�tj|jt��|j|�Wd|j�XdS)NT)rC)rDrErFrrrHrJrB)r&rArrr�test_addsitedir�sz$HelperFunctionsTests.test_addsitedirz<requires access to PEP 370 user-site (site.ENABLE_USER_SITE)cCs"tj}|j|tj�tjj�}tj	tj
dd|g|d�}|j|d�tjj�}tj	tj
ddd|g|d�}|tj�dkr�|j|d�n|j|d�tjj�}d|d<tj	tj
dd|g|d�}|tj�dkr�|j|d�n|j|d�tjj�}d	|d
<tj	tj
ddg|d�}|j|d�dS)Nz-cz$import sys; sys.exit(%r in sys.path))�envr4z-sr�1ZPYTHONNOUSERSITEz/tmp�PYTHONUSERBASEz=import sys, site; sys.exit(site.USER_BASE.startswith("/tmp")))
rrr9r	r
r�environr�
subprocess�call�
executabler/�getsitepackages)r&Zusersitere�rcrrr�
test_s_option�s8






z"HelperFunctionsTests.test_s_optionc
Cshdt_tj�}|jtj|�dt_ddl}d|_t��(}d|d<|jtj�jd�tj��WdQRXdS)Nr�xoxorg)	rr�getuserbaser/r"r#r�
assertTrue�
startswith)r&�	user_baser"rhrrr�test_getuserbase�sz%HelperFunctionsTests.test_getuserbasecCsLdt_dt_tj�}|jtj|�|j|jtj�|�|jtjtj��dS)N)rrr�getusersitepackagesr/rqrrrp)r&�	user_siterrr�test_getusersitepackages�sz-HelperFunctionsTests.test_getusersitepackagescCsdgt_tj�}tjdkr|tjd�r|dgt_tj�}|jt|�d�t	j
jdtjd�dtjdd�d�}|j|d	|�n�t	j
d
kr�|jt|�d�t	j
jdddtjdd�d�}|j|d
|�n@|jt|�d�|j|d
d�t	j
jddd�}|j|d	|�dS)Nro�darwin�PYTHONFRAMEWORKzPython.framework�z/Libraryz%d.%dz
site-packagesr4�/�lib64zpython%d.%dr�lib)rr rlr	�platformr"�get_config_varr/�lenrr
r-�version_info�sep)r&�dirsZwantedrrr�test_getsitepackages�s,



z)HelperFunctionsTests.test_getsitepackagesc%Csdt_dt_dt_t��h}tjddd���L|d=|d=tj�}|j	|j
dtj�|�tj
�}|j	|j
|�|�WdQRXWdQRXtjddd	��f}tjjtd
��L}tjtdd��2t�}tj|�|j|�|j�|j|�WdQRXWdQRXWdQRXdS)
Nzos.path.expandusercSs|S)Nr)r
rrrrQ sz=HelperFunctionsTests.test_no_home_directory.<locals>.<lambda>rg�APPDATA�~z
os.path.isdirF)Zreturn_valuerr
T)rrrr"r#rrZpatchrprqrrrr�ru�objectrZ	swap_attrrJ�addusersitepackagesZassert_called_once_withZassert_not_calledr?)r&rhrsrvZ
mock_isdirZmock_addsitedir�known_pathsrrr�test_no_home_directorys(&

z+HelperFunctionsTests.test_no_home_directoryN)�__name__�
__module__�__qualname__�__doc__r'r*r3r;rBrKrrWr_rarcrdr�
skipUnlessrr
rnrtrwr�r�rrrrr8s"	


&
rc@s4eZdZdZedddfdd�Zdd�Zd
d
d�ZdS)rDz/Helper class for handling testing of .pth filesZtimeZ__testdir__Z__badcCsj|d|_tjjd�|_tjj|j|j�|_||_||_||_	tjj|j|j�|_
tjj|j|j	�|_dS)zInitialize instance variablesz.pth�N)rIrr
r0rHr-�	file_pathr<�good_dirname�bad_dirnamer>r@)r&�
filename_baser<r�r�rrr�__init__=s
zPthFile.__init__c
Csrt|jd�}zJtd|d�td|d�td|j|d�t|j|d�t|j|d�Wd|j�Xtj|j	�dS)aoCreate a .pth file with a comment, blank lines, an ``import
        <self.imported>``, a line with self.good_dirname, and a line with
        self.bad_dirname.

        Creation of the directory for self.good_dir_path (based off of
        self.good_dirname) is also performed.

        Make sure to call self.cleanup() to undo anything done by this method.

        rMz#import @bad module name)�file�
z	import %sN)
rRr��printr<r�r�rTr�mkdirr>)r&ZFILErrrrFIs
zPthFile.createFcCs�tjj|j�rtj|j�|r@tjj|j�|_	|j	rTtj|j=n|j	rT|j	tj|j<tjj|j
�rntj|j
�tjj|j�r�tj|j�dS)z�Make sure that the .pth file is deleted, self.imported is not in
        sys.modules, and that both self.good_dirname and self.bad_dirname are
        not existing directories.N)
rr
r5r�rOr	r=�getr<Zimported_moduler>�rmdirr@)r&rCrrrrE_szPthFile.cleanupN)F)r�r�r�r�rr�rFrErrrrrD:s
rDc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zej	d
�dd��Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zejjd�ejjejejddkd�ejeejd�d�dd�����ZdS) �ImportSideEffectTestsz(Test side-effects from importing 'site'.cCstjdd�|_dS)zMake a copy of sys.pathN)r	r
r)r&rrrr'tszImportSideEffectTests.setUpcCs|jtjdd�<dS)zRestore sys.pathN)rr	r
)r&rrrr*xszImportSideEffectTests.tearDowncCs�y"tjjtjjtj��}tj�}Wn.tk
rPtjjtjjtj��\}}YnXt|���tj	j
�}||d<d}dj|�}tj
tjdd	|g|tjd
�}|j�\}}|j|jd�|j�dd�\}	}
|jtjj|	��|jtjj|
��tj
tjd	|g|tjd
�}|j�\}}|j|jd�|j�dd�\}	}
|jtjj|	�d
j|	jd���|jtjj|
�d
j|
jd���WdQRXdS)N�
PYTHONPATH�import os, sys�9os_file = os.__file__.encode("ascii", "backslashreplace")�(sys.stdout.buffer.write(os_file + b"\n")�=os_cached = os.__cached__.encode("ascii", "backslashreplace")�*sys.stdout.buffer.write(os_cached + b"\n")r�z-Sz-c)re�stdoutrrzzexpected absolute path, got {}�ascii)r�r�r�r�r�)rr
�relpath�dirname�__file__�getcwdrb�splitrrhrr-ri�Popenr	rk�PIPE�communicater/�
returncode�
splitlinesr?�isabsrq�format�decode)r&�parent�cwdre�codeZcommand�procr��stderrZ
os__file__Zos__cached__rrr�test_abs_paths|sD 



z$ImportSideEffectTests.test_abs_pathscCs8tj�t�}x$tjD]}|j||�|j|�qWdS)N)r�removeduppathsrJr	r
�assertNotIn�add)r&Z
seen_pathsr
rrr�test_no_duplicate_paths�s
z-ImportSideEffectTests.test_no_duplicate_pathsztest not implementedcCsdS)Nr)r&rrr�test_add_build_dir�sz(ImportSideEffectTests.test_add_build_dircCs$|jttd��|jttd��dS)N�quit�exit)rq�hasattr�builtins)r&rrr�test_setting_quit�sz'ImportSideEffectTests.test_setting_quitcCs4|jttd��|jttd��|jttd��dS)N�	copyright�credits�license)rqr�r�)r&rrr�test_setting_copyright�sz,ImportSideEffectTests.test_setting_copyrightcCs|jttd��dS)N�help)rqr�r�)r&rrr�test_setting_help�sz'ImportSideEffectTests.test_setting_helpcCsRtjdkrNddl}|j�djd�rNx(tjjj�D]}|dkr2Pq2W|jd�dS)N�win32rr4Zcp�mbcszdid not alias mbcs)	r	r~�localeZgetdefaultlocalerr�	encodings�aliases�values�fail)r&r��valuerrr�test_aliasing_mbcs�s
z(ImportSideEffectTests.test_aliasing_mbcscCs:dtjkr6yddl}Wntk
r*YnX|jd�dS)N�
sitecustomizerz(sitecustomize not imported automatically)r	r=r��ImportErrorr�)r&r�rrr�test_sitecustomize_executed�s
z1ImportSideEffectTests.test_sitecustomize_executedZnetwork��finalzonly for released versionsZHTTPSHandlerz$need SSL support to download licensecCs�tjj�d}tjj|dd�}y<tjj|��&tjj	|��}|j
�}WdQRXWdQRXWn,tjjk
r�}z|j
}WYdd}~XnX|j|dd|d�dS)Nr4ZHEAD)�method��zCan't find )�msg)r��_Printer__datar��urllib�requestZRequest�testrZtransient_internetZurlopenZgetcode�errorZ	HTTPErrorr�r/)r&ZurlZreq�datar��errr�test_license_exists_at_url�s	 z0ImportSideEffectTests.test_license_exists_at_urlN)r�r�r�r�r'r*r�r�r�skipr�r�r�r�r�r�r�rZrequires_resourceZsystem_must_validate_certr�r	r�r�r�r�r�rrrrr�qs"1	


r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zed	d
��Zedd��Z	ed
d��Z
eje
jdkd�dd��Zeje
jdkd�dd��ZdS)�StartupImportTestsc
Cs�tjtjddddgtjtjdd�}|j�\}}t|�}|jd|�dd	d
ddh}tjd
krl|j	|j
|�|�|jd||�tjd
kr�|jd||�ddddddddddh
jtj
�}tjd
kr�|j	|j
|�|�dS)Nz-Iz-vz-cz#import sys; print(set(sys.modules))zutf-8)r�r�rNrr\�_sre�sre_compile�
sre_constants�	sre_parserxr��copyreg�_collections�collections�	functools�heapq�	itertools�keyword�operator�reprlib�types�weakref)rir�r	rkr�r��evalr9r~r?�intersectionr��
difference�builtin_module_names)r&�popenr�r�r=Zre_modsZcollection_modsrrr�test_startup_imports�s(



z'StartupImportTests.test_startup_importscCs&tjtjddg�j�}|j|d�dS)Nz-cz9import sys; sys.exit(hasattr(sys, "__interactivehook__"))z''__interactivehook__' not added by site)rir�r	rk�waitrq)r&�rrrr�test_startup_interactivehooks
z/StartupImportTests.test_startup_interactivehookcCs(tjtjdddg�j�}|j|d�dS)Nz-Iz-cz9import sys; sys.exit(hasattr(sys, "__interactivehook__"))z,'__interactivehook__' added in isolated mode)rir�r	rkr�r?)r&r�rrr�%test_startup_interactivehook_isolatedsz8StartupImportTests.test_startup_interactivehook_isolatedcCs(tjtjdddg�j�}|j|d�dS)Nz-Iz-czYimport site, sys; site.enablerlcompleter(); sys.exit(hasattr(sys, "__interactivehook__"))z6'__interactivehook__' not added by enablerlcompleter())rir�r	rkr�rq)r&r�rrr�.test_startup_interactivehook_isolated_explicit!szAStartupImportTests.test_startup_interactivehook_isolated_explicitcCs�tjjtjd�tjjtj�d�}tjtj|�tjj	|�dd}y4t
|d�� }x|D]}t||d�qXWWdQRX|Stj
j|�tj
j|��YnXdS)NZTEMPr4rz._pthrM)r�)rr
r-�getenvr�r	rk�shutilr�splitextrRr�r�r�unlink)r&�lines�exe_file�	_pth_file�f�linerrr�_create_underpth_exe's"
z'StartupImportTests._create_underpth_execCs0tjj|�dd}tjj|�tjj|�dS)Nrz._pth)rr
r�r�rr)r&rrrrr�_cleanup_underpth_exe7sz(StartupImportTests._cleanup_underpth_execCsJg}x@|D]8}|s
|ddkr"q
tjjtjj||��}|j|�q
W|S)Nr�#)rr
r0r-�append)r&�
sys_prefixrrrZabs_pathrrr�"_calc_sys_path_for_underpth_nosite=s
z5StartupImportTests._calc_sys_path_for_underpth_nositer�zonly supported on Windowscs�tjjtjjtj���tjjtj�}d�fdd�td�D�d�}|j|�}|j	tjj|�|�}zDtj
j�}d|d<d	j|tj
d
��|d
<tj|dd|g|d
�}Wd|j|�X|j|d�dS)N�fake-path-namecsg|]}��qSrr)r6�_)�libpathrrr7Msz@StartupImportTests.test_underpth_nosite_file.<locals>.<listcomp>r�r��	# commentzfrom-envr�z{};{}�PATHz-czRimport sys; sys.exit(sys.flags.no_site and len(sys.path) > 200 and sys.path == %r))rezsys.path is incorrect)r)r�r)rr
r�r�r�r	rk�rangerrrhrr�r�rirjrrq)r&�
exe_prefixZ	pth_linesrrrermr)rr�test_underpth_nosite_fileGs(


z,StartupImportTests.test_underpth_nosite_filecs�tjjtjjtj���tjjtj�}|jd�fdd�td�D�d��}tjj|�}z^tj	j
�}d|d	<d
j|tjd��|d<t
j|dd
tjj|d��tjj|d�fg|d�}Wd|j|�X|j|d�dS)N�fake-path-namecsg|]}��qSrr)r6r
)rrrr7isz9StartupImportTests.test_underpth_file.<locals>.<listcomp>r�r��	# comment�import sitezfrom-envr�z{};{}rz-cz�import sys; sys.exit(not sys.flags.no_site and %r in sys.path and %r in sys.path and %r not in sys.path and all("\r" not in p and "\n" not in p for p in sys.path)))rezsys.path is incorrect)r)r�rr)rr
r�r�r�r	rkrrrhrr�r�rirjr-rrq)r&rrr
rermr)rr�test_underpth_filecs*
z%StartupImportTests.test_underpth_fileN)r�r�r�r�r�r�r��classmethodrrrrr�r	r~rrrrrrr��s 
r��__main__)%r�rZtest.supportr�rrrrrr�rr	r\r�Zurllib.requestr�Zurllib.errorr�rir"rr�flags�no_siterrrrrZTestCaserr�rDr�r�r��mainrrrr�<module>s@
7


Youez - 2016 - github.com/yon3zu
LinuXploit