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.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)?cCs2t�d�}t|jt�sJ�t�|j|j�s.J�dS)N�distinfo-pkg)r�	from_name�
isinstancer�str�re�match�version_pattern)�self�dist�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__rrrrrrrrr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_namecCs$tdddd�}|��tjus J�dS)Nr-zimportlib.metadataZgrp)�namer/�group)rr+r$r
)rr-rrr�test_resolve_without_attr8s�z%ImportTests.test_resolve_without_attrN)rr r!r&r.r0r3rrrrr"'sr"c@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�}t|�dksJ�dS)z�
        For a package with a dash in the name, the dist-info metadata
        uses underscores in the name. Ensure the metadata loads.
        �1.0N)r?r=r�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-infor5r6r7NZCherryPyr8r<rrr�pkg_with_mixed_caseXs(z*NameNormalizationTests.pkg_with_mixed_casecCsH|�|j�}t|�dksJ�t|���dks0J�t|���dksDJ�dS)zG
        Ensure the metadata loads when queried with any case.
        r@N)rDr=r�lower�upperrArrr� test_dist_name_found_as_any_caseesz7NameNormalizationTests.test_dist_name_found_as_any_caseN)rr r!�staticmethodr?rCrDrGrrrrr4As

r4c@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-infor5r6�utf-8��encodinguDescription: pôrˈtend
N�portendr8�r=r>r
�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.
        rJr5r6rKrLuK
                Name: portend

                pôrˈtend
                NrN)r9r:r;�textwrap�dedent�lstriprOrrr�'pkg_with_non_ascii_description_egg_info}s2z5NonASCIITests.pkg_with_non_ascii_description_egg_infocCs(|�|j�}t|�}|ddks$J�dS)NZDescriptionu
pôrˈtend)rQr=r
�rrB�metarrr�test_metadata_loads�sz!NonASCIITests.test_metadata_loadscCs(|�|j�}t|�}|��dks$J�dS)Nupôrˈtend
)rUr=r
Zget_payloadrVrrr�test_metadata_loads_egg_info�sz*NonASCIITests.test_metadata_loads_egg_infoN)rr r!rHrQrUrXrYrrrrrIos

rIc@seZdZdd�Zdd�ZdS)�DiscoveryTestscCsPtt��}tdd�|D��s J�tdd�|D��s6J�tdd�|D��sLJ�dS)Ncss|]}t|t�VqdSr)rr��.0rrrr�	<genexpr>�s�z8DiscoveryTests.test_package_discovery.<locals>.<genexpr>css|]}|jddkVqdS)�Namezegginfo-pkgN�r
r[rrrr]�s�css|]}|jddkVqdS)r^r
Nr_r[rrrr]�s�)�listr�all�any)rZdistsrrr�test_package_discovery�s
���z%DiscoveryTests.test_package_discoverycCs>|�t�� ttddd��Wd�n1s00YdS)NZ	something�else)�contextr1)r�
ValueErrorr`rrrrr�test_invalid_usage�sz!DiscoveryTests.test_invalid_usageN)rr r!rcrgrrrrrZ�srZc@seZdZdd�Zdd�ZdS)�
DirectoryTestcCsF|j�d���|�t��td�Wd�n1s80YdS)NzEGG-INFOzunknown-package)r=�joinpathr9rrrrrrr�
test_egg_info�szDirectoryTest.test_egg_infoc	Cst|j�d�}|��|�|��B|�t��td�Wd�n1sH0YWd�n1sf0YdS)Nzfoo-3.6.eggZfoo)r=rir9Zadd_sys_pathrrr)rZeggrrr�test_egg�s
zDirectoryTest.test_eggN)rr r!rjrkrrrrrh�srhc@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)rr r!r=rnrrrrrl�srlcs(eZdZdZ�fdd�Zdd�Z�ZS)�InaccessibleSysPathz/access-deniedcs,tt|���|��|jj|jdd�dS)Nr)Z	perm_bits)�superro�setUpZ
setUpPyfakefsZfsZ
create_dirr=r��	__class__rrrq�szInaccessibleSysPath.setUpcCsttj���dSrm)r`r$r
rrrrrrn�sz"InaccessibleSysPath.test_discovery)rr r!r=rqrn�
__classcell__rrrrrro�srocsTeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�ZS)�TestEntryPointscs&tt|�j|�tj�ddd�|_dS)Nr1r/r2)rpru�__init__r$r
rr-)r�argsrrrrrv�szTestEntryPoints.__init__cCs$t�t�|j��}||jks 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-r1rrrr�test_immutable�szTestEntryPoints.test_immutablecCs:dt|j�vsJ�dt|j�vs$J�dt|j�vs6J�dS)Nrzname=z'name')�reprr-rrrr�	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�jsonrzr-rrrr�test_json_dump�szTestEntryPoints.test_json_dumpcCs|jjdksJ�dS)Nr/)r-�modulerrrr�test_module�szTestEntryPoints.test_modulecCs|jjdusJ�dSr)r-�attrrrrr�	test_attr�szTestEntryPoints.test_attr)rr r!rvr{r}rr�r�r�r�rtrrrrrru�sruc@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_filenamer=r`rrrrr�test_unicode_dir_on_sys_paths

�z'FileSystem.test_unicode_dir_on_sys_pathN)rr r!r�rrrrr�sr�)%rr�rxrRZunittest�importlib.metadatar$Z!pyfakefs.fake_filesystem_unittestrZffsr#Zstubs�rrrrrr	r
rZDistInfoPkgZTestCaserr"Z	OnSysPathZSiteDirr4rIZ
EggInfoPkgrZrhrlroruZFileBuilderr�rrrr�<module>s:$
�.*�%
�