a  ze @sddlZddlZddlZddlZddlZddlZzddlmZ Wne y^ddl mZ Yn0ddl m Z ddlmZmZmZmZmZmZmZGddde jejZGdd d e jejZGd d d e je jejZGd d d e je jejZGddde je jejZGddde je jejZGddde jejZ Gddde je jZ!GdddejZ"Gddde je je j#ejZ$dS)N)fake_filesystem_unittest)fixtures) Distribution EntryPointPackageNotFoundError distributions entry_pointsmetadataversionc@s(eZdZdZddZddZddZdS) BasicTestsz\d+\.\d+(\.\d)?cCs2td}t|jtsJt|j|js.JdS)N distinfo-pkg)r from_name isinstancer strrematchversion_pattern)selfdistrQ/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_importlib/test_main.pytest_retrieves_version_of_selfs z)BasicTests.test_retrieves_version_of_selfcCs8|ttdWdn1s*0YdS)Nzdoes-not-exist) assertRaisesrrrrrrrtest_for_name_does_not_exists z'BasicTests.test_for_name_does_not_existcCs|ttdSN)ZassertIsInstancertyperrrrtest_new_style_classes#sz!BasicTests.test_new_style_classesN)__name__ __module__ __qualname__rrrrrrrrr sr c@s,eZdZddZddZddZddZd S) ImportTestscCs8|ttdWdn1s*0YdS)NZdoes_not_exist)r ImportError importlib import_modulerrrrtest_import_nonexistent_module(s z*ImportTests.test_import_nonexistent_modulecCs,ttd}|d}||jddS)Nentriesmain)dictr assertEqualloadrrr'eprrr test_resolve.szImportTests.test_resolvecCs(ttd}|d}||jddS)Nr'zns:subzmod:main)r)r r*valuer,rrr"test_entrypoint_with_colon_in_name3sz.ImportTests.test_entrypoint_with_colon_in_namecCs$tdddd}|tjus JdS)Nr-zimportlib.metadatagrp)namer/group)rr+r$r )rr-rrrtest_resolve_without_attr8s z%ImportTests.test_resolve_without_attrN)rr r!r&r.r0r4rrrrr"'sr"c@s4eZdZeddZddZeddZddZd S) NameNormalizationTestscCsP|d}||d}|d}|dWdn1sB0YdS)z Create minimal metadata for a package with dashes in the name (and thus underscores in the filename). zmy_pkg.dist-infoMETADATAw Version: 1.0 Nzmy-pkgmkdiropenwritesite_dir metadata_dirr Zstrmrrrpkg_with_dashesCs  (z&NameNormalizationTests.pkg_with_dashescCs ||j}t|dksJdS)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 rpkg_namerrr-test_dashes_in_dist_name_found_as_underscoresPs zDNameNormalizationTests.test_dashes_in_dist_name_found_as_underscorescCsP|d}||d}|d}|dWdn1sB0YdS)z\ Create minimal metadata for a package with mixed case in the name. zCherryPy.dist-infor6r7r8NZCherryPyr9r=rrrpkg_with_mixed_caseXs  (z*NameNormalizationTests.pkg_with_mixed_casecCsH||j}t|dksJt|dks0Jt|dksDJdS)zG Ensure the metadata loads when queried with any case. rAN)rEr>r lowerupperrBrrr test_dist_name_found_as_any_casees z7NameNormalizationTests.test_dist_name_found_as_any_caseN)rr r! staticmethodr@rDrErHrrrrr5As   r5c@s4eZdZeddZeddZddZddZd S) NonASCIITestscCsT|d}||d}|jddd}|dWdn1sF0YdS) zb Create minimal metadata for a package with non-ASCII in the description. portend.dist-infor6r7utf-8encodinguDescription: pôrˈtend Nportendr9r>r?r fprrrpkg_with_non_ascii_descriptionps (z,NonASCIITests.pkg_with_non_ascii_descriptioncCs^|d}||d}|jddd$}|tdWdn1sP0YdS) zl Create minimal metadata for an egg-info package with non-ASCII in the description. rKr6r7rLrMuK Name: portend pôrˈtend NrO)r:r;r<textwrapdedentlstriprPrrr'pkg_with_non_ascii_description_egg_info}s 2z5NonASCIITests.pkg_with_non_ascii_description_egg_infocCs(||j}t|}|ddks$JdS)NZ Descriptionu pôrˈtend)rRr>r rrCmetarrrtest_metadata_loadss z!NonASCIITests.test_metadata_loadscCs(||j}t|}|dks$JdS)Nu pôrˈtend )rVr>r Z get_payloadrWrrrtest_metadata_loads_egg_infos z*NonASCIITests.test_metadata_loads_egg_infoN)rr r!rIrRrVrYrZrrrrrJos   rJc@seZdZddZddZdS)DiscoveryTestscCsPtt}tdd|Ds Jtdd|Ds6Jtdd|DsLJdS)Ncss|]}t|tVqdSr)rr.0rrrr sz8DiscoveryTests.test_package_discovery..css|]}|jddkVqdS)Namez egginfo-pkgNr r\rrrr^scss|]}|jddkVqdS)r_r Nr`r\rrrr^s)listrallany)rZdistsrrrtest_package_discoverys   z%DiscoveryTests.test_package_discoverycCs>|t ttdddWdn1s00YdS)NZ somethingelse)contextr2)r ValueErrorrarrrrrtest_invalid_usages z!DiscoveryTests.test_invalid_usageN)rr r!rdrhrrrrr[sr[c@seZdZddZddZdS) DirectoryTestcCsF|jd|ttdWdn1s80YdS)NzEGG-INFOzunknown-package)r>joinpathr:rrr rrrr test_egg_infos zDirectoryTest.test_egg_infoc Cst|jd}|||B|ttdWdn1sH0YWdn1sf0YdS)Nz foo-3.6.eggZfoo)r>rjr:Z add_sys_pathrrr )rZeggrrrtest_eggs    zDirectoryTest.test_eggN)rr r!rkrlrrrrrisric@seZdZdZddZdS)MissingSysPathz/does-not-existcCstjdSzp Discovering distributions should succeed even if there is an invalid path on sys.path. N)r$r rrrrrtest_discoveryszMissingSysPath.test_discoveryN)rr r!r>rorrrrrmsrmcs(eZdZdZfddZddZZS)InaccessibleSysPathz/access-deniedcs,tt|||jj|jdddS)Nr)Z perm_bits)superrpsetUpZ setUpPyfakefsfsZ create_dirr>r __class__rrrrszInaccessibleSysPath.setUpcCsttjdSrn)rar$r rrrrrrosz"InaccessibleSysPath.test_discovery)rr r!r>rrro __classcell__rrrtrrps rpcsTeZdZfddZddZddZddZd d Zd d Zd dZ ddZ Z S)TestEntryPointscs&tt|j|tjddd|_dS)Nr2r/r3)rqrw__init__r$r rr-)rargsrtrrrxszTestEntryPoints.__init__cCs$tt|j}||jks JdSr)pickleloadsdumpsr-)rZrevivedrrrtest_entry_point_pickleablesz+TestEntryPoints.test_entry_point_pickleablecCs6|td|j_Wdn1s(0YdS)zEntryPoints should be immutableZbadactorN)rAttributeErrorr-r2rrrrtest_immutables zTestEntryPoints.test_immutablecCs:dt|jvsJdt|jvs$Jdt|jvs6JdS)Nrzname=z'name')reprr-rrrr test_reprszTestEntryPoints.test_reprcCst|jdS)zEntryPoints should be hashableN)hashr-rrrr test_hashableszTestEntryPoints.test_hashablecCs:|tt|jWdn1s,0YdS)zI json should not expect to be able to dump an EntryPoint N)r Exceptionjsonr|r-rrrrtest_json_dumps zTestEntryPoints.test_json_dumpcCs|jjdksJdS)Nr/)r-modulerrrr test_moduleszTestEntryPoints.test_modulecCs|jjdusJdSr)r-attrrrrr test_attrszTestEntryPoints.test_attr) rr r!rxr}rrrrrrrvrrrtrrws rwc@seZdZddZdS) FileSystemcCs&tj|ii|jdttdS)zb Ensure a Unicode subdirectory of a directory on sys.path does not crash. )prefixN)rZ build_filesZunicode_filenamer>rarrrrrtest_unicode_dir_on_sys_paths  z'FileSystem.test_unicode_dir_on_sys_pathN)rr r!rrrrrrsr)%rrrzrSZunittestimportlib.metadatar$Z!pyfakefs.fake_filesystem_unittestrZffsr#Zstubsrrrrrr r r Z DistInfoPkgZTestCaser r"Z OnSysPathZSiteDirr5rJZ EggInfoPkgr[rirmrprwZ FileBuilderrrrrrs:  $  .* %