Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.116.49.66
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_pkgutil.cpython-310.pyc
o

ab�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/local/python-3.10/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_DATAZpackage_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(Ziter_modules�assertIsInstanceZ
ModuleInfo�append�namer))
r�zipr*r+�zip_file�zr-r.�namesZ
moduleinforrrr/;s*z!PkgutilTests.test_getdata_zipfilecCsRd}tj�|j|�}t�|d�|�tj|�tj|jgd�D]}|�	d�qdS)NZunreadable_packager)rzunexpected package found)
r rr!r
r"r�rmdirr&�
walk_packagesZfail)rZ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.modrBztest_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&r>r(�endswithrr))	r�pkg1Zpkg1_dirr,�pkg2Zpkg2_dir�expected�actualr*rrrrBis8



�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_zipfilerr0r1r2�/z/mod.pyr)rzsub.test_walkpackages_zipfilez!sub.test_walkpackages_zipfile.modrQztest_walkpackages_zipfile.subz!test_walkpackages_zipfile.sub.modcSrCrDrrFrrrrI�rJz:PkgutilTests.test_walkpackages_zipfile.<locals>.<listcomp>rKN)r rr!r
r3r4r5r$rrr&r>r(rLr))	rr9rMrNr:r;rOrPr*rrrrQ�s,

�z&PkgutilTests.test_walkpackages_zipfilecCs�d}|�ttf��tt�|��Wd�n1swYd}|�ttf��tt�|��Wd�dS1s<wYdS)NZtest_dirstest_dir)�assertRaises�	TypeError�
ValueError�listr&r>)r�	str_inputZbytes_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:pathrEg@Tr2z?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.9abcZ9abc)	u	वमस�é�Èu안녕하세요uさよならuありがとうuХорошоuспасибоu现代汉语常用字表��exist_okrr0���u०वमस)�s)rYZlogging.handlersr r�pathsep�handlersZ
SysLogHandlerZ	LOG_ALERT�int�
from_bytesr[rTrU�ImportError�AttributeErrorr!r
�makedirs�UnicodeEncodeErrorr#r%�flush�	importlib�invalidate_caches�
import_module�lenZsubTestr&�resolve_namer(rS)
rrYZ
success_casesZ
failure_casesZ
unicode_wordsZuwr?r,rKrarO�o�excrrr�test_name_resolution�s�


����	�

�
�
�������z!PkgutilTests.test_name_resolutionN)�__name__�
__module__�__qualname__rrrr/rArBrQrXrrrrrrrs#(#
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�loadsrrE)�__dict__�get)rrKrrr�exec_module sz+PkgutilPEP302Tests.MyTestLoader.exec_modulecCsdS)N�
Hello, world!r)rrrrrr'$rzz(PkgutilPEP302Tests.MyTestLoader.get_dataN)rsrtruryr~r'rrrr�MyTestLoadersr�c@seZdZddd�ZdS)z!PkgutilPEP302Tests.MyTestImporterNcCs t��}t|d|jj|gd�S)Nz<%s>)�loader�submodule_search_locations)rvr�r�	__class__rs)r�fullnamer�targetr�rrr�	find_spec(s
�z+PkgutilPEP302Tests.MyTestImporter.find_spec)NN)rsrtrur�rrrr�MyTestImporter'sr�cCstj�d|���dSr)r�	meta_pathrr�rrrrr/szPkgutilPEP302Tests.setUpcCrr)rr�rrrrr2rzPkgutilPEP302Tests.tearDowncCs |�t�dd�d�tjd=dS)NrZ�dummyr)r(r&r'rr)rrrr�test_getdata_pep3025sz&PkgutilPEP302Tests.test_getdata_pep302cCsDddl}|�|jd�|�t�dd�d�|�|jd�tjd=dS)NrrErZr�r)rZr(r{r&r'rr))rrZrrr�test_alreadyloaded:s
z%PkgutilPEP302Tests.test_alreadyloadedN)
rsrtru�objectr�r�rrr�r�rrrrrvsrvc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ExtendPathTestscCsrt��}tj�d|�tj�||�}t�|�ttj�|d�d��}|�	d�Wd�|S1s2wY|S)Nrrr0zKfrom pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
)
rr	rrrr r!r"r#r%)r�pkgnamer
Zpkgdir�flrrr�create_initHs

��zExtendPathTests.create_initcCsVtj�|||d�}t|d��}td�|�|d�Wd�dS1s$wYdS)N�.pyr0zvalue={})�file)r rr!r#�print�format)rr
r�Zsubmodule_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)NrZ�barr�bazrE�foo.bar�foo.baz)r�r��foo.bar�foo.bazr(r�r�r��sorted�__path__r rr!rr
rr)�rr�Z	dirname_0Z	dirname_1rZrrr�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�spamZeggsz{}.{}rzinvalid.modulez.spamz	spam.eggs)r&�iter_importers�get_importerr�r rr!r�rr)�popr�rkrmrV�	_get_specr�rgr6�	machinery�
FileFinderr(�SourceFileLoader�assertIsNonerSrfrr
�KeyError)
rr�r�r��modnamer
Zpathitemr�Z	importersZexpected_importer�finderrxr�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)	NrZr�rrr�rEr�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)rsrtrur�r�r�r�r�rrrrr�Gs0r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�NestedNamespacePackageTestcCst��|_tjdd�|_dSrw)rr	�basedirrr�old_pathrrrrr�s
z NestedNamespacePackageTest.setUpcCs |jtjdd�<t�|j�dSrw)r�rrrr
r�rrrrr�sz#NestedNamespacePackageTest.tearDowncCs�|�dd�\}}tj�|j|�dtjj��}tj|dd�ttj�||d�d��}|�	|�Wd�dS1s:wYdS)N�.rETr^r�r0)
�rsplitr rr!r��replace�seprhr#r%)rr8�contents�base�final�	base_pathr,rrrry�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)r?rE)ryrrrr r!r�r*rrr(rnr�Z
pkg.subpkgZsubpkgZpkg.subpkg.cr�Zpkg.subpkg.dr?)rZpkgutil_boilerplater*r�r?rrr�test_nested�s(�z&NestedNamespacePackageTest.test_nestedN)rsrtrurrryr�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�Nr2)r�r&ZImpImporterrrrr�test_importer_deprecated�s
"�z0ImportlibMigrationTests.test_importer_deprecatedcCs>|���t�dddd�Wd�dS1swYdSr�)r�r&Z	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(rn�warnings�rr0rrr� 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�rsr(rnr�)rZthis_loaderr0rrr�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��rr8rKr�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��rr8r�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&r�r(rnr�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(rnr�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(rnr�)rr0Zimporterrrr�$test_iter_importers_avoids_emulation@s"�z<ImportlibMigrationTests.test_iter_importers_avoids_emulationN)rsrtrur�r�r�r��unittestZskipIfr�r�r�r�r�r�r�r�rrrrr��s
			r�cCs&ddl}ddl}|j��|��dSr)�	zipimportrk�_zip_directory_cache�clearrl)r�rkrrr�tearDownModuleFs
r�r�)Ztest.support.import_helperrrZtest.support.warnings_helperrr�rrk�importlib.utilrr&r Zos.pathrrr3ZTestCaserrvr�r�r�r�rs�mainrrrr�<module>s.-})Y�
© 2025 GrazzMean