Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/test_importlib/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/test_importlib/__pycache__/test_main.cpython-39.opt-1.pyc

a

XC?h� �@s�ddlZddlZddlZddlZddlZddlZzddlmZ	Wne
y^ddlmZ	Yn0ddlm
Z
ddlmZmZmZmZmZmZmZGdd�de
jej�ZGdd	�d	e
jej�ZGd
d�de
je
jej�ZGdd
�d
e
je
jej�ZGdd�de
je
jej�ZGdd�de
je
jej�ZGdd�de
jej�Z Gdd�de
je	j�Z!Gdd�dej�Z"Gdd�de
je
je
j#ej�Z$dS)�N�)�fake_filesystem_unittest)�fixtures)�Distribution�
EntryPoint�PackageNotFoundError�
distributions�entry_points�metadata�versionc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
BasicTestsz\d+\.\d+(\.\d)?cCst�d�}dS)Nzdistinfo-pkg)r�	from_name)�selfZdist�r�B/opt/alt/python39/lib64/python3.9/test/test_importlib/test_main.py�test_retrieves_version_of_selfs
z)BasicTests.test_retrieves_version_of_selfcCs8|�t��t�d�Wd�n1s*0YdS)Nzdoes-not-exist)�assertRaisesrrr
�rrrr�test_for_name_does_not_existsz'BasicTests.test_for_name_does_not_existcCs|�tt�dS�N)ZassertIsInstancer�typerrrr�test_new_style_classes#sz!BasicTests.test_new_style_classesN)�__name__�
__module__�__qualname__Zversion_patternrrrrrrrrsrc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ImportTestscCs8|�t��t�d�Wd�n1s*0YdS)NZdoes_not_exist)r�ImportError�	importlib�
import_modulerrrr�test_import_nonexistent_module(sz*ImportTests.test_import_nonexistent_modulecCs,tt�d�}|d}|�|��jd�dS)N�entries�main)�dictr	�assertEqual�loadr�rr �eprrr�test_resolve.szImportTests.test_resolvecCs(tt�d�}|d}|�|jd�dS)Nr zns:subzmod:main)r"r	r#�valuer%rrr�"test_entrypoint_with_colon_in_name3sz.ImportTests.test_entrypoint_with_colon_in_namecCstdddd�}dS)Nr&zimportlib.metadataZgrp)�namer(�group)r)rr&rrr�test_resolve_without_attr8s�z%ImportTests.test_resolve_without_attrN)rrrrr'r)r,rrrrr'src@s4eZdZedd��Zdd�Zedd��Zdd�Zd	S)
�NameNormalizationTestscCsP|d}|��|d}|�d��}|�d�Wd�n1sB0YdS)z
        Create minimal metadata for a package with dashes
        in the name (and thus underscores in the filename).
        zmy_pkg.dist-info�METADATA�w�
Version: 1.0
Nzmy-pkg��mkdir�open�write��site_dir�metadata_dirr
Zstrmrrr�pkg_with_dashesCs(z&NameNormalizationTests.pkg_with_dashescCs|�|j�}dS)z�
        For a package with a dash in the name, the dist-info metadata
        uses underscores in the name. Ensure the metadata loads.
        N)r8r6�r�pkg_namerrr�-test_dashes_in_dist_name_found_as_underscoresPszDNameNormalizationTests.test_dashes_in_dist_name_found_as_underscorescCsP|d}|��|d}|�d��}|�d�Wd�n1sB0YdS)z\
        Create minimal metadata for a package with mixed case
        in the name.
        zCherryPy.dist-infor.r/r0NZCherryPyr1r5rrr�pkg_with_mixed_caseXs(z*NameNormalizationTests.pkg_with_mixed_casecCs|�|j�}dS)zG
        Ensure the metadata loads when queried with any case.
        N)r<r6r9rrr� test_dist_name_found_as_any_caseesz7NameNormalizationTests.test_dist_name_found_as_any_caseN)rrr�staticmethodr8r;r<r=rrrrr-As

r-c@s4eZdZedd��Zedd��Zdd�Zdd�Zd	S)
�
NonASCIITestscCsT|d}|��|d}|jddd��}|�d�Wd�n1sF0YdS)	zb
        Create minimal metadata for a package with non-ASCII in
        the description.
        �portend.dist-infor.r/�utf-8��encodinguDescription: pôrˈtend
N�portendr1�r6r7r
�fprrr�pkg_with_non_ascii_descriptionps(z,NonASCIITests.pkg_with_non_ascii_descriptioncCs^|d}|��|d}|jddd��$}|�t�d����Wd�n1sP0YdS)	zl
        Create minimal metadata for an egg-info package with
        non-ASCII in the description.
        r@r.r/rArBuK
                Name: portend

                pôrˈtend
                NrD)r2r3r4�textwrap�dedent�lstriprErrr�'pkg_with_non_ascii_description_egg_info}s2z5NonASCIITests.pkg_with_non_ascii_description_egg_infocCs|�|j�}t|�}dSr)rGr6r
�rr:�metarrr�test_metadata_loads�sz!NonASCIITests.test_metadata_loadscCs|�|j�}t|�}dSr)rKr6r
rLrrr�test_metadata_loads_egg_info�sz*NonASCIITests.test_metadata_loads_egg_infoN)rrrr>rGrKrNrOrrrrr?os

r?c@seZdZdd�Zdd�ZdS)�DiscoveryTestscCstt��}dSr)�listr)rZdistsrrr�test_package_discovery�s
	z%DiscoveryTests.test_package_discoverycCs>|�t�� ttddd��Wd�n1s00YdS)NZ	something�else)�contextr*)r�
ValueErrorrQrrrrr�test_invalid_usage�sz!DiscoveryTests.test_invalid_usageN)rrrrRrVrrrrrP�srPc@seZdZdd�Zdd�ZdS)�
DirectoryTestcCsF|j�d���|�t��td�Wd�n1s80YdS)NzEGG-INFOzunknown-package)r6�joinpathr2rrrrrrr�
test_egg_info�szDirectoryTest.test_egg_infoc	Cst|j�d�}|��|�|��B|�t��td�Wd�n1sH0YWd�n1sf0YdS)Nzfoo-3.6.eggZfoo)r6rXr2Zadd_sys_pathrrr)rZeggrrr�test_egg�s
zDirectoryTest.test_eggN)rrrrYrZrrrrrW�srWc@seZdZdZdd�ZdS)�MissingSysPathz/does-not-existcCstj��dS�zp
        Discovering distributions should succeed even if
        there is an invalid path on sys.path.
        N)rr
rrrrr�test_discovery�szMissingSysPath.test_discoveryN)rrrr6r]rrrrr[�sr[cs(eZdZdZ�fdd�Zdd�Z�ZS)�InaccessibleSysPathz/access-deniedcs,tt|���|��|jj|jdd�dS)Nr)Z	perm_bits)�superr^�setUpZ
setUpPyfakefsZfsZ
create_dirr6r��	__class__rrr`�szInaccessibleSysPath.setUpcCsttj���dSr\)rQrr
rrrrrr]�sz"InaccessibleSysPath.test_discovery)rrrr6r`r]�
__classcell__rrrarr^�sr^csTeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�ZS)�TestEntryPointscs&tt|�j|�tj�ddd�|_dS)Nr*r(r+)r_rd�__init__rr
rr&)r�argsrarrre�szTestEntryPoints.__init__cCst�t�|j��}dSr)�pickle�loads�dumpsr&)rZrevivedrrr�test_entry_point_pickleable�sz+TestEntryPoints.test_entry_point_pickleablecCs6|�t��d|j_Wd�n1s(0YdS)zEntryPoints should be immutableZbadactorN)r�AttributeErrorr&r*rrrr�test_immutable�szTestEntryPoints.test_immutablecCsdSrrrrrr�	test_repr�szTestEntryPoints.test_reprcCst|j�dS)zEntryPoints should be hashableN)�hashr&rrrr�
test_hashable�szTestEntryPoints.test_hashablecCs:|�t��t�|j�Wd�n1s,0YdS)zI
        json should not expect to be able to dump an EntryPoint
        N)r�	Exception�jsonrir&rrrr�test_json_dump�szTestEntryPoints.test_json_dumpcCsdSrrrrrr�test_module�szTestEntryPoints.test_modulecCsdSrrrrrr�	test_attr�szTestEntryPoints.test_attr)rrrrerjrlrmrorrrsrtrcrrrarrd�srdc@seZdZdd�ZdS)�
FileSystemcCs&tj|��ii|jd�tt��dS)zb
        Ensure a Unicode subdirectory of a directory on sys.path
        does not crash.
        )�prefixN)rZbuild_filesZunicode_filenamer6rQrrrrr�test_unicode_dir_on_sys_paths

�z'FileSystem.test_unicode_dir_on_sys_pathN)rrrrwrrrrrusru)%�rerqrgrHZunittest�importlib.metadatarZ!pyfakefs.fake_filesystem_unittestrZffsrZstubs�rrrrrr	r
rZDistInfoPkgZTestCaserrZ	OnSysPathZSiteDirr-r?Z
EggInfoPkgrPrWr[r^rdZFileBuilderrurrrr�<module>s:$
�.*�%
�