Your IP : 216.73.216.52


Current Path : /opt/alt/python310/lib64/python3.10/test/test_importlib/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/test_importlib/__pycache__/test_main.cpython-310.pyc

o

0�i#�@s�ddlZddlZddlZddlZddlZddlZddlZzddlm	Z
Wney3ddlm	Z
Ynwddl
mZddlmZmZmZmZmZmZmZGdd�dejej�ZGdd	�d	ejej�ZGd
d�dejejej�ZGdd
�d
ejejej�ZGdd�dejejej�ZGdd�dejejej�Z Gdd�dejej�Z!Gdd�deje
j�Z"Gdd�dej�Z#Gdd�dejejej$ej�Z%dS)�N�)�fake_filesystem_unittest)�fixtures)�Distribution�
EntryPoint�PackageNotFoundError�
distributions�entry_points�metadata�versionc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�
BasicTestsz\d+\.\d+(\.\d)?cCs2t�d�}t|jt�s
J�t�|j|j�sJ�dS)N�distinfo-pkg)r�	from_name�
isinstancer�str�re�match�version_pattern)�self�dist�r�D/opt/alt/python310/lib64/python3.10/test/test_importlib/test_main.py�test_retrieves_version_of_selfs
z)BasicTests.test_retrieves_version_of_selfcC�:|�t��t�d�Wd�dS1swYdS)N�does-not-exist)�assertRaisesrrr�rrrr�test_for_name_does_not_exist"s"�z'BasicTests.test_for_name_does_not_existcCsJ|�t��
}t�d�Wd�n1swYdt|j�vs#J�dS)Nrr
)rrrrrZ	exception)r�ctxrrr�(test_package_not_found_mentions_metadata&s�z3BasicTests.test_package_not_found_mentions_metadatacCs|�tt�dS�N)ZassertIsInstancer�typerrrr�test_new_style_classes0sz!BasicTests.test_new_style_classesN)�__name__�
__module__�__qualname__rrrrr"rrrrrs
rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ImportTestscCr)NZdoes_not_exist)r�ImportError�	importlib�
import_modulerrrr�test_import_nonexistent_module5s"�z*ImportTests.test_import_nonexistent_modulecCs$tdd�d}|�|��jd�dS)N�entries��group�main)r	�assertEqual�loadr#�r�eprrr�test_resolve;szImportTests.test_resolvecCs tdd�d}|�|jd�dS)Nr+r,zns:subzmod:main)r	r/�valuer1rrr�"test_entrypoint_with_colon_in_name?sz.ImportTests.test_entrypoint_with_colon_in_namecCs$tdddd�}|��tjusJ�dS)Nr2zimportlib.metadataZgrp)�namer4r-)rr0r(r
r1rrr�test_resolve_without_attrCs�z%ImportTests.test_resolve_without_attrN)r#r$r%r*r3r5r7rrrrr&4s
r&c@s4eZdZedd��Zdd�Zedd��Zdd�Zd	S)
�NameNormalizationTestscC�V|d}|��|d}|jddd��}|�d�Wd�dS1s$wYdS)	z
        Create minimal metadata for a package with dashes
        in the name (and thus underscores in the filename).
        zmy_pkg.dist-info�METADATA�w�utf-8��encoding�
Version: 1.0
Nzmy-pkg��mkdir�open�write��site_dir�metadata_dirr
Zstrmrrr�pkg_with_dashesM�
��z&NameNormalizationTests.pkg_with_dashescCs |�|j�}t|�dksJ�dS�Nz1.0)rGrEr�r�pkg_namerrr�-test_dashes_in_dist_name_found_as_underscoresZszDNameNormalizationTests.test_dashes_in_dist_name_found_as_underscorescCr9)	z\
        Create minimal metadata for a package with mixed case
        in the name.
        zCherryPy.dist-infor:r;r<r=r?NZCherryPyr@rDrrr�pkg_with_mixed_case`rHz*NameNormalizationTests.pkg_with_mixed_casecCsH|�|j�}t|�dksJ�t|���dksJ�t|���dks"J�dSrI)rMrEr�lower�upperrJrrr� test_dist_name_found_as_any_casemsz7NameNormalizationTests.test_dist_name_found_as_any_caseN)r#r$r%�staticmethodrGrLrMrPrrrrr8Ls

r8c@s4eZdZedd��Zedd��Zdd�Zdd�Zd	S)
�
NonASCIITestscCr9)	zb
        Create minimal metadata for a package with non-ASCII in
        the description.
        �portend.dist-infor:r;r<r=uDescription: pôrˈtendN�portendr@�rErFr
�fprrr�pkg_with_non_ascii_descriptionvrHz,NonASCIITests.pkg_with_non_ascii_descriptioncCs`|d}|��|d}|jddd��}|�t�d����Wd�dS1s)wYdS)	zl
        Create minimal metadata for an egg-info package with
        non-ASCII in the description.
        rSr:r;r<r=uK
                Name: portend

                pôrˈtend
                NrT)rArBrC�textwrap�dedent�striprUrrr�'pkg_with_non_ascii_description_egg_info�s��
�
�
z5NonASCIITests.pkg_with_non_ascii_description_egg_infocC�(|�|j�}t|�}|ddksJ�dS�NZDescriptionu
pôrˈtend)rWrEr
�rrK�metarrr�test_metadata_loads��z!NonASCIITests.test_metadata_loadscCr\r])r[rEr
r^rrr�test_metadata_loads_egg_info�raz*NonASCIITests.test_metadata_loads_egg_infoN)r#r$r%rQrWr[r`rbrrrrrRus

rRc@�eZdZdd�Zdd�ZdS)�DiscoveryTestscCsPtt��}tdd�|D��sJ�tdd�|D��sJ�tdd�|D��s&J�dS)Ncss�|]}t|t�VqdSr )rr��.0rrrr�	<genexpr>�s�z8DiscoveryTests.test_package_discovery.<locals>.<genexpr>cs��|]
}|jddkVqdS)�Namezegginfo-pkgN�r
rerrrrg���csrh)rir
Nrjrerrrrg�rk)�listr�all�any)rZdistsrrr�test_package_discovery�s
z%DiscoveryTests.test_package_discoverycCs@|�t��ttddd��Wd�dS1swYdS)NZ	something�else)�contextr6)r�
ValueErrorrlrrrrr�test_invalid_usage�s"�z!DiscoveryTests.test_invalid_usageN)r#r$r%rorsrrrrrd�srdc@rc)�
DirectoryTestcCsH|j�d���|�t��
td�Wd�dS1swYdS)NzEGG-INFOzunknown-package)rE�joinpathrArrrrrrr�
test_egg_info�s
"�zDirectoryTest.test_egg_infoc	Cs�|j�d�}|��|�|��*|�t��td�Wd�n1s$wYWd�dSWd�dS1s<wYdS)Nzfoo-3.6.eggZfoo)rErurAZadd_sys_pathrrr)rZeggrrr�test_egg�s
��"�zDirectoryTest.test_eggN)r#r$r%rvrwrrrrrt�srtc@seZdZdZdd�ZdS)�MissingSysPathz/does-not-existcCstj��dS�zp
        Discovering distributions should succeed even if
        there is an invalid path on sys.path.
        N)r(r
rrrrr�test_discovery�szMissingSysPath.test_discoveryN)r#r$r%rErzrrrrrx�srxcs(eZdZdZ�fdd�Zdd�Z�ZS)�InaccessibleSysPathz/access-deniedcs,tt|���|��|jj|jdd�dS)Nr)Z	perm_bits)�superr{�setUpZ
setUpPyfakefsZfsZ
create_dirrEr��	__class__rrr}�szInaccessibleSysPath.setUpcCsttj���dSry)rlr(r
rrrrrrz�sz"InaccessibleSysPath.test_discovery)r#r$r%rEr}rz�
__classcell__rrr~rr{�sr{cs\eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Z�ZS)�TestEntryPointscs&tt|�j|�tj�ddd�|_dS)Nr6r4r-)r|r��__init__r(r
rr2)r�argsr~rrr��szTestEntryPoints.__init__cCs$t�t�|j��}||jksJ�dSr )�pickle�loads�dumpsr2)rZrevivedrrr�test_entry_point_pickleable�sz+TestEntryPoints.test_entry_point_pickleablecCs8|�t��
d|j_Wd�dS1swYdS)zEntryPoints should be immutableZbadactorN)r�AttributeErrorr2r6rrrr�test_immutable�s
"�zTestEntryPoints.test_immutablecCs:dt|j�vs	J�dt|j�vsJ�dt|j�vsJ�dS)Nrzname=z'name')�reprr2rrrr�	test_repr�szTestEntryPoints.test_reprcCst|j�dSr )�hashr2rrrr�
test_hashable�szTestEntryPoints.test_hashablec	Csx|�t��-tjdd��t�|j�Wd�n1swYWd�dSWd�dS1s5wYdS)NT)�record)r�	Exception�warnings�catch_warnings�jsonr�r2rrrr�test_json_dump�s��"�zTestEntryPoints.test_json_dumpcCs|jjdksJ�dS)Nr4)r2�modulerrrr�test_module��zTestEntryPoints.test_modulecCs|jjdusJ�dSr )r2�attrrrrr�	test_attr�r�zTestEntryPoints.test_attrcCs ttddd�tddd�g�dS)N�b�valr-�a)�sortedrrrrr�
test_sortable�s


��zTestEntryPoints.test_sortable)
r#r$r%r�r�r�r�r�r�r�r�r�r�rrr~rr��sr�c@seZdZdd�ZdS)�
FileSystemcCs&tj|��ii|jd�tt��dS)N)�prefix)rZbuild_filesZunicode_filenamerErlrrrrr�test_unicode_dir_on_sys_path
s

�z'FileSystem.test_unicode_dir_on_sys_pathN)r#r$r%r�rrrrr�sr�)&rr�r�rXZunittestr��importlib.metadatar(Z!pyfakefs.fake_filesystem_unittestrZffsr'Zstubs�rrrrrr	r
rZDistInfoPkgZTestCaserr&Z	OnSysPathZSiteDirr8rRZ
EggInfoPkgrdrtrxr{r�ZFileBuilderr�rrrr�<module>s4�$).
-�