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)?cCstd}dS)Nz distinfo-pkg)r from_name)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) assertRaisesrrr rrrrtest_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__Zversion_patternrrrrrrrr 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_namecCstdddd}dS)Nr'zimportlib.metadatagrp)namer)group)r)rr'rrrtest_resolve_without_attr8s z%ImportTests.test_resolve_without_attrN)rrrr r(r*r.rrrrr'src@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}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)r:r8rpkg_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-infor0r1r2NZCherryPyr3r7rrrpkg_with_mixed_caseXs  (z*NameNormalizationTests.pkg_with_mixed_casecCs||j}dS)zG Ensure the metadata loads when queried with any case. N)r>r8r;rrr test_dist_name_found_as_any_casees z7NameNormalizationTests.test_dist_name_found_as_any_caseN)rrr staticmethodr:r=r>r?rrrrr/As   r/c@s4eZdZeddZeddZddZddZd S) NonASCIITestscCsT|d}||d}|jddd}|dWdn1sF0YdS) zb Create minimal metadata for a package with non-ASCII in the description. portend.dist-infor0r1utf-8encodinguDescription: pôrˈtend Nportendr3r8r9r 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. rBr0r1rCrDuK Name: portend pôrˈtend NrF)r4r5r6textwrapdedentlstriprGrrr'pkg_with_non_ascii_description_egg_info}s 2z5NonASCIITests.pkg_with_non_ascii_description_egg_infocCs||j}t|}dSr)rIr8r rr<metarrrtest_metadata_loadss z!NonASCIITests.test_metadata_loadscCs||j}t|}dSr)rMr8r rNrrrtest_metadata_loads_egg_infos z*NonASCIITests.test_metadata_loads_egg_infoN)rrrr@rIrMrPrQrrrrrAos   rAc@seZdZddZddZdS)DiscoveryTestscCstt}dSr)listr)rZdistsrrrtest_package_discoverys z%DiscoveryTests.test_package_discoverycCs>|t ttdddWdn1s00YdS)NZ somethingelse)contextr,)r ValueErrorrSrrrrrtest_invalid_usages z!DiscoveryTests.test_invalid_usageN)rrrrTrXrrrrrRsrRc@seZdZddZddZdS) DirectoryTestcCsF|jd|ttdWdn1s80YdS)NzEGG-INFOzunknown-package)r8joinpathr4rrr rrrr test_egg_infos zDirectoryTest.test_egg_infoc Cst|jd}|||B|ttdWdn1sH0YWdn1sf0YdS)Nz foo-3.6.eggZfoo)r8rZr4Z add_sys_pathrrr )rZeggrrrtest_eggs    zDirectoryTest.test_eggN)rrrr[r\rrrrrYsrYc@seZdZdZddZdS)MissingSysPathz/does-not-existcCstjdSzp Discovering distributions should succeed even if there is an invalid path on sys.path. N)rr rrrrrtest_discoveryszMissingSysPath.test_discoveryN)rrrr8r_rrrrr]sr]cs(eZdZdZfddZddZZS)InaccessibleSysPathz/access-deniedcs,tt|||jj|jdddS)Nr)Z perm_bits)superr`setUpZ setUpPyfakefsfsZ create_dirr8r __class__rrrbszInaccessibleSysPath.setUpcCsttjdSr^)rSrr rrrrrr_sz"InaccessibleSysPath.test_discovery)rrrr8rbr_ __classcell__rrrdrr`s r`csTeZdZfddZddZddZddZd d Zd d Zd dZ ddZ Z S)TestEntryPointscs&tt|j|tjddd|_dS)Nr,r)r-)rarg__init__rr rr')rargsrdrrrhszTestEntryPoints.__init__cCstt|j}dSr)pickleloadsdumpsr')rZrevivedrrrtest_entry_point_pickleablesz+TestEntryPoints.test_entry_point_pickleablecCs6|td|j_Wdn1s(0YdS)zEntryPoints should be immutableZbadactorN)rAttributeErrorr'r,rrrrtest_immutables zTestEntryPoints.test_immutablecCsdSrrrrrr 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 Exceptionjsonrlr'rrrrtest_json_dumps zTestEntryPoints.test_json_dumpcCsdSrrrrrr test_moduleszTestEntryPoints.test_modulecCsdSrrrrrr test_attrszTestEntryPoints.test_attr) rrrrhrmrorprrrurvrwrfrrrdrrgs rgc@seZdZddZdS) FileSystemcCs&tj|ii|jdttdS)zb Ensure a Unicode subdirectory of a directory on sys.path does not crash. )prefixN)rZ build_filesZunicode_filenamer8rSrrrrrtest_unicode_dir_on_sys_paths  z'FileSystem.test_unicode_dir_on_sys_pathN)rrrrzrrrrrxsrx)%rertrjrJZunittestimportlib.metadatarZ!pyfakefs.fake_filesystem_unittestrZffsrZstubsrrrrrr r r Z DistInfoPkgZTestCaser rZ OnSysPathZSiteDirr/rAZ EggInfoPkgrRrYr]r`rgZ FileBuilderrxrrrrs:  $  .* %