a  ze @sddlZddlZddlZddlmZddlmZddlmZm Z m Z m Z m Z m Z mZmZGdddejejejejZGdd d ejejZdS) N)Iterator)fixtures) DistributionPackageNotFoundError distribution entry_pointsfilesmetadatarequiresversionc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ e ddZ ddZ ddZddZddZddZddZddZd d!Zd"S)#APITestsz\d+\.\d+(\.\d)?cCs,td}t|tsJt|j|s(JdSN egginfo-pkgr isinstancestrrematchversion_patternselfZ pkg_versionrY/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_importlib/test_metadata_api.pytest_retrieves_version_of_selfsz'APITests.test_retrieves_version_of_selfcCs,td}t|tsJt|j|s(JdSN distinfo-pkgrrrrr&test_retrieves_version_of_distinfo_pkgsz/APITests.test_retrieves_version_of_distinfo_pkgcCs6|ttdWdn1s(0YdS)Nzdoes-not-exist)Z assertRaisesrrrrrrtest_for_name_does_not_exist s z%APITests.test_for_name_does_not_existcCs|tddddS)Nr top_level.txtmod) assertEqualr read_textstriprrrrtest_for_top_level$szAPITests.test_for_top_levelcCs*ddtdDd}||ddS)NcSsg|]}|jdkr|qS)r name).0pathrrr *s z+APITests.test_read_text..rrzmod )r r"r#)rZ top_levelrrrtest_read_text)s zAPITests.test_read_textcCs6ttd}|d}||jd||jgdS)Nentriesmainzmod:main)dictrr"valueextras)rr,Zeprrrtest_entry_points0szAPITests.test_entry_pointscCsRtd}|ddksJ|ddks(J|ddks8J|d}d|vsNJdS) NrZauthorz Steven MaLICENSEZUnknownNameZ Classifierz*Topic :: Software Development :: Libraries)r Zget_all)rZmdZ classifiersrrrtest_metadata_for_this_package6s  z'APITests.test_metadata_for_this_packagecCs|dj}|D]}|j|ks J|jr2|jjs2J|jrH|jjdksHJ|jr\|jdks\J|slJt|t s~J|j dr| qdS)NrZsha256z.py) roothashr/modesizeZlocateexistsrZ read_binarybytesr'endswithr#)r r5filerrr _test_files>s  zAPITests._test_filescCs0|j}ddtdDd}|t|jddS)NcSsg|]}|jdkr|qS)zmod.pyr&)r(prrrr*Ns z0APITests.test_file_hash_repr..rrz!) assertRegexr reprr6)rr?utilrrrtest_file_hash_reprKszAPITests.test_file_hash_reprcCs|tddSrr=r rrrrtest_files_dist_infoVszAPITests.test_files_dist_infocCs|tddSrrCrrrrtest_files_egg_infoYszAPITests.test_files_egg_infocCs|tdddS)N egginfo-filez0.1)r"r rrrrtest_version_egg_info_file\sz#APITests.test_version_egg_info_filecCstd}||dS)NrF)r Z assertIsNone)rZ requirementsrrrtest_requires_egg_info_file_sz$APITests.test_requires_egg_info_filecCs2td}t|dksJtdd|Ds.JdS)Nrcss|]}|dkVqdS)z%wheel >= 1.0; python_version >= "2.7"Nr)r(Zdeprrr fsz2APITests.test_requires_egg_info..)r lenanyrdepsrrrtest_requires_egg_infocs zAPITests.test_requires_egg_infocCs@td}t|dksJt|s$Jd|vs0Jd|vs= 1.0zpytest; extra == 'test')r rKallrMrrrtest_requires_dist_infoks   z APITests.test_requires_dist_infocCs0td}tt|}gd}||ks,JdS)Nz dep1 dep2 [:python_version < "3"] dep3 [extra1] dep4 [extra2:python_version < "3"] dep5 )Zdep1Zdep2zdep3; python_version < "3"zdep4; extra == "extra1"z2dep5; (python_version < "3") and extra == "extra2")textwrapdedentsortedrZ_deps_from_requires_text)rr rNZexpectedrrr$test_more_complex_deps_requires_textrs  z-APITests.test_more_complex_deps_requires_textN)__name__ __module__ __qualname__rrrrr%r+r1r4 staticmethodr=rBrDrErGrHrOrQrUrrrrr s$  r c@s$eZdZddZddZddZdS)OffSysPathTestscCs.tjt|jgd}tdd|Ds*JdS)N)r)css|]}|jddkVqdS)r3rN)r )r(distrrrrJszIOffSysPathTests.test_find_distributions_specified_path..)rZdiscoverrsite_dirrL)rZdistsrrr&test_find_distributions_specified_pathsz6OffSysPathTests.test_find_distributions_specified_pathcCs&|jd}t|}|jdks"JdS)zBDemonstrate how to load metadata direct from a directory. distinfo_pkg-1.0.0.dist-info1.0.0N)r\ratr rZdist_info_pathr[rrrtest_distribution_at_pathlibs  z,OffSysPathTests.test_distribution_at_pathlibcCs*|jd}tt|}|jdks&JdS)Nr^r_)r\rr`rr rarrrtest_distribution_at_strs z(OffSysPathTests.test_distribution_at_strN)rVrWrXr]rbrcrrrrrZsrZ)rrRZunittestcollections.abcrrimportlib.metadatarrrrr r r r Z EggInfoPkgZ DistInfoPkgZ EggInfoFileZTestCaser ZDistInfoPkgOffPathrZrrrrs  (