Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_pkgutil.cpython-310.pyc
o

�9j�T�@s�ddlmZmZddlmZddlZddlZddlZddlm	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZGdd�dej�ZGdd�dej�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�Zdd�Zedkrse��dSdS)�)�unload�CleanImport)�check_warningsN)�spec_from_file_locationc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�PkgutilTestscCs.t��|_|�tj|j�tj�d|j�dS�Nr)	�tempfile�mkdtemp�dirname�
addCleanup�shutil�rmtree�sys�path�insert��self�r�(/usr/lib/python3.10/test/test_pkgutil.py�setUps
zPkgutilTests.setUpcC�tjd=dSr)rrrrrr�tearDown�zPkgutilTests.tearDowncCs�d}d}tj�|j|�}t�|�ttj�|d�d�}|��ttj�|d�d�}|�|�|��t�tj�|d��ttj�|dd�d�}|�|�|��t�	|d�}|�
||�t�	|d�}|�
||�tj|=dS)N�test_getdata_filesys�%Hello, world!
Second line
Third line�__init__.py�wb�res.txt�sub�sub/res.txt)
�osr�joinr
�mkdir�open�close�write�pkgutil�get_data�assertEqualr�modules)r�pkg�
RESOURCE_DATA�package_dir�f�res1�res2rrrrs$


z!PkgutilTests.test_getdata_filesysc
Cs�d}d}d}tj�|j|�}t�|d�}|�|dd�|�|d|�|�|d|�|��tj�	d	|�t
�|d
�}|�||�t
�|d�}|�||�g}t
�
|g�D]}	|�|	t
j�|�|	j�qW|�|dg�tjd	=tj|=dS)Nztest_getdata_zipfile.zip�test_getdata_zipfiler�w�/__init__.py�z/res.txtz/sub/res.txtrrr)r rr!r
�zipfile�ZipFile�writestrr$rrr&r'r(�iter_modules�assertIsInstance�
ModuleInfo�append�namer))
r�zipr*r+�zip_file�zr.r/�names�
moduleinforrrr0;s*z!PkgutilTests.test_getdata_zipfilecCsRd}tj�|j|�}t�|d�|�tj|�tj|jgd�D]}|�	d�qdS)N�unreadable_packager)rzunexpected package found)
r rr!r
r"r�rmdirr&�
walk_packages�fail)r�package_name�d�trrr�test_unreadable_dir_on_syspath^s�z+PkgutilTests.test_unreadable_dir_on_syspathc	Csbd}tj�|j|�}t�|�ttj�|d�d�}|��t�tj�|d��ttj�|dd�d�}|��ttj�|dd�d�}|��d}tj�|j|�}t�|�ttj�|d�d�}|��t�tj�|d��ttj�|dd�d�}|��ttj�|dd�d�}|��gd�}dd�t�|jg�D�}|�	||�|D]}|�
d	�r�q�tj|=q�dS)
N�test_walkpackages_filesysrrrzmod.py)rzsub.test_walkpackages_filesysz!sub.test_walkpackages_filesys.modrIztest_walkpackages_filesys.subz!test_walkpackages_filesys.sub.modcS�g|]}|d�qS��r��.0�errr�
<listcomp>��z:PkgutilTests.test_walkpackages_filesys.<locals>.<listcomp>�mod)
r rr!r
r"r#r$r&rCr(�endswithrr))	r�pkg1�pkg1_dirr-�pkg2�pkg2_dir�expected�actualr*rrrrIis8



�z&PkgutilTests.test_walkpackages_filesysc	Csd}d}d}tj�|j|�}t�|d�}|�|dd�|�|d|dd�|�|d|dd�|�|dd�|�|d|dd�|�|d|dd�|��tj�	d	|�gd
�}dd�t
�|g�D�}|�||�tjd	=|D]}|�
d
�r�qztj|=qzdS)zBTests the same as test_walkpackages_filesys, only with a zip file.ztest_walkpackages_zipfile.zip�test_walkpackages_zipfilerr1r2r3�/z/mod.pyr)rzsub.test_walkpackages_zipfilez!sub.test_walkpackages_zipfile.modrZztest_walkpackages_zipfile.subz!test_walkpackages_zipfile.sub.modcSrJrKrrMrrrrP�rQz:PkgutilTests.test_walkpackages_zipfile.<locals>.<listcomp>rRN)r rr!r
r4r5r6r$rrr&rCr(rSr))	rr<rTrVr=r>rXrYr*rrrrZ�s,

�z&PkgutilTests.test_walkpackages_zipfilecCs�d}|�ttf��tt�|��Wd�n1swYd}|�ttf��tt�|��Wd�dS1s<wYdS)N�test_dirstest_dir)�assertRaises�	TypeError�
ValueError�listr&rC)r�	str_input�bytes_inputrrr�2test_walk_packages_raises_on_string_or_bytes_input�s�"�z?PkgutilTests.test_walk_packages_raises_on_string_or_bytes_inputc
Cs�ddl}ddl}dtfdtjfdtjjfd|fd|fd|jfd|jfd	|jjfd
|jjfd|jjjfd|jjjfd
tfdtfdtj	fdtj	fdt
fdt
fdtjff}dtfdtfdtfdtfdtfdtfdtfdt
fdtfdt
fdt
fdtfdtfd tfd!t
fd"tfd#tff}d$}|D]c}tj�|j|�}z	tj|dd%�Wn	ty�Yq�wtj�|d&�}t|d'��}|�d�|��Wd�n1s�wYt��t�|�}|||ff7}t|�dkr�||dd(�t
ff7}q�|d)tff7}|D]&\}	}
|j|	d*��t�|	�}|�||
�Wd�n	1�swYq�|D]7\}	}|j|	d*��#|�|��
t�|	�Wd�n	1�sBwYWd�n	1�sRwY�q!dS)+Nrr zos.pathzos.path:pathsep�loggingzlogging:zlogging.handlerszlogging.handlers:zlogging.handlers:SysLogHandlerzlogging.handlers.SysLogHandlerz(logging.handlers:SysLogHandler.LOG_ALERTz(logging.handlers.SysLogHandler.LOG_ALERTzbuiltins.intzbuiltins:intzbuiltins.int.from_byteszbuiltins:int.from_byteszbuiltins.ZeroDivisionErrorzbuiltins:ZeroDivisionErrorzos:pathrLg@Tr3z?abczabc/foo�foozos.foozos.foo:zos.pth:pathsepzlogging.handlers:NoSuchHandlerz,logging.handlers:SysLogHandler.NO_SUCH_VALUEz,logging.handlers.SysLogHandler.NO_SUCH_VALUE�ZeroDivisionErrorzos.path.9abc�9abc)	u	वमस�é�Èu안녕하세요uさよならuありがとうuХорошоuспасибоu现代汉语常用字表��exist_okrr1���u०वमस)�s)rd�logging.handlersr r�pathsep�handlers�
SysLogHandler�	LOG_ALERT�int�
from_bytesrfr^r_�ImportError�AttributeErrorr!r
�makedirs�UnicodeEncodeErrorr#r%�flush�	importlib�invalidate_caches�
import_module�len�subTestr&�resolve_namer(r])
rrd�
success_cases�
failure_cases�
unicode_words�uwrFr-rRrmrX�o�excrrr�test_name_resolution�s�


����	�

�
�
�������z!PkgutilTests.test_name_resolutionN)�__name__�
__module__�__qualname__rrrr0rHrIrZrcr�rrrrrs#(#
rc@sLeZdZGdd�de�ZGdd�de�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�PkgutilPEP302Testsc@s$eZdZdd�Zdd�Zdd�ZdS)zPkgutilPEP302Tests.MyTestLoadercCsdS�Nr)r�specrrr�
create_module�z-PkgutilPEP302Tests.MyTestLoader.create_modulecCs|j�dd�d|jd<dS)N�loadsrrL)�__dict__�get)rrRrrr�exec_module sz+PkgutilPEP302Tests.MyTestLoader.exec_modulecCsdS)N�
Hello, world!r)rrrrrr'$r�z(PkgutilPEP302Tests.MyTestLoader.get_dataN)r�r�r�r�r�r'rrrr�MyTestLoadersr�c@seZdZddd�ZdS)z!PkgutilPEP302Tests.MyTestImporterNcCs t��}t|d|jj|gd�S)Nz<%s>)�loader�submodule_search_locations)r�r�r�	__class__r�)r�fullnamer�targetr�rrr�	find_spec(s
�z+PkgutilPEP302Tests.MyTestImporter.find_spec)NN)r�r�r�r�rrrr�MyTestImporter'sr�cCstj�d|���dSr)r�	meta_pathrr�rrrrr/szPkgutilPEP302Tests.setUpcCrr)rr�rrrrr2rzPkgutilPEP302Tests.tearDowncCs |�t�dd�d�tjd=dS)Nre�dummyr�)r(r&r'rr)rrrr�test_getdata_pep3025sz&PkgutilPEP302Tests.test_getdata_pep302cCsDddl}|�|jd�|�t�dd�d�|�|jd�tjd=dS)NrrLrer�r�)rer(r�r&r'rr))rrerrr�test_alreadyloaded:s
z%PkgutilPEP302Tests.test_alreadyloadedN)
r�r�r��objectr�r�rrr�r�rrrrr�sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ExtendPathTestscCsrt��}tj�d|�tj�||�}t�|�ttj�|d�d��}|�	d�Wd�|S1s2wY|S)Nrrr1zKfrom pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
)
rr	rrrr r!r"r#r%)r�pkgnamer
�pkgdir�flrrr�create_initHs

��zExtendPathTests.create_initcCsVtj�|||d�}t|d��}td�|�|d�Wd�dS1s$wYdS)N�.pyr1zvalue={})�file)r rr!r#�print�format)rr
r��submodule_name�value�module_namer�rrr�create_submoduleSs"�z ExtendPathTests.create_submodulec	Cs�d}|�|�}|�|�}|�||dd�|�||dd�ddl}ddl}|�|jjd�|�|jjd�|�t|j	�tt
j�||�t
j�||�g��t
�|�t
�|�tjd=tjd=tjd=tjd=tjd=dS)Nre�barr�bazrL�foo.bar�foo.baz)r�r��foo.bar�foo.bazr(r�r�r��sorted�__path__r rr!rr
rr)�rr��	dirname_0�	dirname_1rerrr�test_simpleXs*

��

zExtendPathTests.test_simplec
Cs�tj}tj}d}d}|�|�}tj�||�}d�||�}tj	�
|d�tj	�
|d�z�|�|||d�t�
|�t||��}||�}	|D]9}
t�|
|�}|j}z|j}Wn	ty]Ynw|�|
tjj�|�|
|	�|�|tjj�|�t�|
|��qD|�t��t|d��Wd�n1s�wY|�t��t|d��Wd�n1s�wYWt�|�tjd=ztj	d=tj	d=WdSty�YdSwt�|�tjd=z
tj	d=tj	d=Wwty�Yww)N�spam�eggsz{}.{}rzinvalid.modulez.spamz	spam.eggs)r&�iter_importers�get_importerr�r rr!r�rr)�popr�rzr|r`�	_get_specr�rvr8�	machinery�
FileFinderr(�SourceFileLoader�assertIsNoner]rurr
�KeyError)
rr�r�r��modnamer
�pathitemr��	importers�expected_importer�finderr�r�rrr�test_iter_importersusf


�����
�
��z#ExtendPathTests.test_iter_importersc	Cs�d}|�|�}|�|�}|�||dd�t�tj�||d��|�||dd�ddl}ddl}|�|j	j
d�|�|jj
d�|�t|j
�ttj�||�tj�||�g��t�|�t�|�tjd=tjd=tjd=tjd=tjd=dS)	Nrer�rrr�rLr�r�)r�r�r �unlinkrr!r�r�r(r�r�r�r�r�rr
rr)r�rrr�test_mixed_namespace�s,

��

z$ExtendPathTests.test_mixed_namespaceN)r�r�r�r�r�r�r�r�rrrrr�Gs0r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�NestedNamespacePackageTestcCst��|_tjdd�|_dSr�)rr	�basedirrr�old_pathrrrrr�s
z NestedNamespacePackageTest.setUpcCs |jtjdd�<t�|j�dSr�)r�rrrr
r�rrrrr�sz#NestedNamespacePackageTest.tearDowncCs�|�dd�\}}tj�|j|�dtjj��}tj|dd�ttj�||d�d��}|�	|�Wd�dS1s:wYdS)N�.rLTrjr�r1)
�rsplitr rr!r��replace�seprwr#r%)rr;�contents�base�final�	base_pathr-rrrr��s"�z(NestedNamespacePackageTest.create_modulecCsd}|�d|�|�d|�|�d|�|�d|�|�dd�|�dd	�tj�d
tj�|jd��tj�d
tj�|jd��d
dl}|�t	d
�|�
t|j�d�d
dl
}|�t	d�|�
t|jj�d�d
dlm}d
dlm}|�
|d�|�
|d�dS)NzBimport pkgutil; __path__ = pkgutil.extend_path(__path__, __name__)za.pkg.__init__zb.pkg.__init__za.pkg.subpkg.__init__zb.pkg.subpkg.__init__za.pkg.subpkg.czc = 1zb.pkg.subpkg.dzd = 2r�a�br*�z
pkg.subpkg)�c)rFrL)r�rrrr r!r�r*rrr(r}r��
pkg.subpkg�subpkg�pkg.subpkg.cr��pkg.subpkg.drF)r�pkgutil_boilerplater*r�rFrrr�test_nested�s(�z&NestedNamespacePackageTest.test_nestedN)r�r�r�rrr�r�rrrrr��s
r�c@s|eZdZdd�Zdd�Zdd�Zdd�Ze�ed	kd
�dd��Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�ImportlibMigrationTestscCstdtf�S)Nz[This emulation is deprecated and slated for removal in Python 3.12; use 'importlib' instead)r�DeprecationWarningrrrr�check_deprecated�s
��z(ImportlibMigrationTests.check_deprecatedcCs8|���t�d�Wd�dS1swYdS�Nr3)r�r&�ImpImporterrrrr�test_importer_deprecated�s
"�z0ImportlibMigrationTests.test_importer_deprecatedcCs>|���t�dddd�Wd�dS1swYdSr�)r�r&�	ImpLoaderrrrr�test_loader_deprecated�s
"�z.ImportlibMigrationTests.test_loader_deprecatedcC�nt��*}|�t�d��|�t�d��|�t�d��|�t|j�d�Wd�dS1s0wYdS�Nrr ztest.supportr)r�assertIsNotNoner&�
get_loaderr(r}�warnings�rr1rrr� test_get_loader_avoids_emulation�"�z8ImportlibMigrationTests.test_get_loader_avoids_emulation�__main__znot compatible with __main__cCsjt}bz.t��}|�t�t��|�t|j�d�Wd�n
1s#wYW|adSW|adS|awr)	�
__loader__rr�r&r�r�r(r}r�)r�this_loaderr1rrr�0test_get_loader_handles_missing_loader_attributes��zHImportlibMigrationTests.test_get_loader_handles_missing_loader_attributecCs^d}tt�|�}|`t|��|tj|<t�|�}Wd�n1s#wY|�|�dS�Nr���typer�__spec__rr)r&r�r��rr;rRr�rrr�.test_get_loader_handles_missing_spec_attributes

�zFImportlibMigrationTests.test_get_loader_handles_missing_spec_attributecCs`d}tt�|�}d|_t|��|tj|<t�|�}Wd�n1s$wY|�|�dSr�r�r�rrr�+test_get_loader_handles_spec_attribute_nones

�zCImportlibMigrationTests.test_get_loader_handles_spec_attribute_nonecCs>d}dtj|<zt�|�}Wtj|=ntj|=w|�|�dS�Nz
totally bogus)rr)r&r�r��rr;r�rrr�#test_get_loader_None_in_sys_modules%s
z;ImportlibMigrationTests.test_get_loader_None_in_sys_modulescCsd}t�|�}|�|�dSr�)r&�find_loaderr�r�rrr�test_find_loader_missing_module.s
z7ImportlibMigrationTests.test_find_loader_missing_modulecCr�r�)rr�r&rr(r}r�r�rrr�!test_find_loader_avoids_emulation3r�z9ImportlibMigrationTests.test_find_loader_avoids_emulationcCsNt��}|�t�d��|�t|j�d�Wd�dS1s wYdS)Nz*??r)rr�r&r�r(r}r�r�rrr�"test_get_importer_avoids_emulation:s"�z:ImportlibMigrationTests.test_get_importer_avoids_emulationcCsLt��}t��D]}q|�t|j�d�Wd�dS1swYdSr)rr&r�r(r}r�)rr1�importerrrr�$test_iter_importers_avoids_emulation@s"�z<ImportlibMigrationTests.test_iter_importers_avoids_emulationN)r�r�r�r�r�r�r��unittest�skipIfr�r�r�r�rrrrrrrrr��s
			r�cCs&ddl}ddl}|j��|��dSr)�	zipimportrz�_zip_directory_cache�clearr{)rrzrrr�tearDownModuleFs
rr�)�test.support.import_helperrr�test.support.warnings_helperrrrrz�importlib.utilrr&r �os.pathrrr4�TestCaserr�r�r�r�rr��mainrrrr�<module>s.-})Y�

Youez - 2016 - github.com/yon3zu
LinuXploit