| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  | import re | 
					
						
							| 
									
										
										
										
											2019-12-10 20:05:10 -05:00
										 |  |  |  | import json | 
					
						
							|  |  |  |  | import pickle | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  | import textwrap | 
					
						
							|  |  |  |  | import unittest | 
					
						
							| 
									
										
										
										
											2021-03-13 11:31:45 -05:00
										 |  |  |  | import warnings | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  | import importlib.metadata | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-11 21:58:47 -05:00
										 |  |  |  | try: | 
					
						
							|  |  |  |  |     import pyfakefs.fake_filesystem_unittest as ffs | 
					
						
							|  |  |  |  | except ImportError: | 
					
						
							| 
									
										
										
										
											2022-01-22 21:38:26 -05:00
										 |  |  |  |     from .stubs import fake_filesystem_unittest as ffs | 
					
						
							| 
									
										
										
										
											2020-02-11 21:58:47 -05:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-22 21:38:26 -05:00
										 |  |  |  | from . import fixtures | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  | from importlib.metadata import ( | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |     Distribution, | 
					
						
							|  |  |  |  |     EntryPoint, | 
					
						
							|  |  |  |  |     PackageNotFoundError, | 
					
						
							|  |  |  |  |     distributions, | 
					
						
							|  |  |  |  |     entry_points, | 
					
						
							|  |  |  |  |     metadata, | 
					
						
							| 
									
										
										
										
											2021-12-16 15:49:42 -05:00
										 |  |  |  |     packages_distributions, | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |     version, | 
					
						
							|  |  |  |  | ) | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | class BasicTests(fixtures.DistInfoPkg, unittest.TestCase): | 
					
						
							|  |  |  |  |     version_pattern = r'\d+\.\d+(\.\d)?' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_retrieves_version_of_self(self): | 
					
						
							|  |  |  |  |         dist = Distribution.from_name('distinfo-pkg') | 
					
						
							|  |  |  |  |         assert isinstance(dist.version, str) | 
					
						
							|  |  |  |  |         assert re.match(self.version_pattern, dist.version) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_for_name_does_not_exist(self): | 
					
						
							|  |  |  |  |         with self.assertRaises(PackageNotFoundError): | 
					
						
							|  |  |  |  |             Distribution.from_name('does-not-exist') | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-19 14:14:21 -07:00
										 |  |  |  |     def test_package_not_found_mentions_metadata(self): | 
					
						
							| 
									
										
										
										
											2021-04-02 12:35:32 -07:00
										 |  |  |  |         # When a package is not found, that could indicate that the | 
					
						
							|  |  |  |  |         # packgae is not installed or that it is installed without | 
					
						
							|  |  |  |  |         # metadata. Ensure the exception mentions metadata to help | 
					
						
							|  |  |  |  |         # guide users toward the cause. See #124. | 
					
						
							| 
									
										
										
										
											2020-10-19 14:14:21 -07:00
										 |  |  |  |         with self.assertRaises(PackageNotFoundError) as ctx: | 
					
						
							|  |  |  |  |             Distribution.from_name('does-not-exist') | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         assert "metadata" in str(ctx.exception) | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |     def test_new_style_classes(self): | 
					
						
							|  |  |  |  |         self.assertIsInstance(Distribution, type) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | class ImportTests(fixtures.DistInfoPkg, unittest.TestCase): | 
					
						
							|  |  |  |  |     def test_import_nonexistent_module(self): | 
					
						
							|  |  |  |  |         # Ensure that the MetadataPathFinder does not crash an import of a | 
					
						
							| 
									
										
										
										
											2019-08-31 06:21:19 +10:00
										 |  |  |  |         # non-existent module. | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |         with self.assertRaises(ImportError): | 
					
						
							|  |  |  |  |             importlib.import_module('does_not_exist') | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_resolve(self): | 
					
						
							| 
									
										
										
										
											2021-03-13 11:31:45 -05:00
										 |  |  |  |         ep = entry_points(group='entries')['main'] | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |         self.assertEqual(ep.load().__name__, "main") | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-28 14:59:24 -04:00
										 |  |  |  |     def test_entrypoint_with_colon_in_name(self): | 
					
						
							| 
									
										
										
										
											2021-03-13 11:31:45 -05:00
										 |  |  |  |         ep = entry_points(group='entries')['ns:sub'] | 
					
						
							| 
									
										
										
										
											2019-07-28 14:59:24 -04:00
										 |  |  |  |         self.assertEqual(ep.value, 'mod:main') | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |     def test_resolve_without_attr(self): | 
					
						
							|  |  |  |  |         ep = EntryPoint( | 
					
						
							|  |  |  |  |             name='ep', | 
					
						
							|  |  |  |  |             value='importlib.metadata', | 
					
						
							|  |  |  |  |             group='grp', | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |         assert ep.load() is importlib.metadata | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  | class NameNormalizationTests(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase): | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |     @staticmethod | 
					
						
							|  |  |  |  |     def pkg_with_dashes(site_dir): | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         Create minimal metadata for a package with dashes | 
					
						
							|  |  |  |  |         in the name (and thus underscores in the filename). | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         metadata_dir = site_dir / 'my_pkg.dist-info' | 
					
						
							|  |  |  |  |         metadata_dir.mkdir() | 
					
						
							|  |  |  |  |         metadata = metadata_dir / 'METADATA' | 
					
						
							| 
									
										
										
										
											2021-04-05 13:11:23 +09:00
										 |  |  |  |         with metadata.open('w', encoding='utf-8') as strm: | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |             strm.write('Version: 1.0\n') | 
					
						
							|  |  |  |  |         return 'my-pkg' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_dashes_in_dist_name_found_as_underscores(self): | 
					
						
							| 
									
										
										
										
											2021-04-02 12:35:32 -07:00
										 |  |  |  |         # For a package with a dash in the name, the dist-info metadata | 
					
						
							|  |  |  |  |         # uses underscores in the name. Ensure the metadata loads. | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |         pkg_name = self.pkg_with_dashes(self.site_dir) | 
					
						
							|  |  |  |  |         assert version(pkg_name) == '1.0' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @staticmethod | 
					
						
							|  |  |  |  |     def pkg_with_mixed_case(site_dir): | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         Create minimal metadata for a package with mixed case | 
					
						
							|  |  |  |  |         in the name. | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         metadata_dir = site_dir / 'CherryPy.dist-info' | 
					
						
							|  |  |  |  |         metadata_dir.mkdir() | 
					
						
							|  |  |  |  |         metadata = metadata_dir / 'METADATA' | 
					
						
							| 
									
										
										
										
											2021-04-05 13:11:23 +09:00
										 |  |  |  |         with metadata.open('w', encoding='utf-8') as strm: | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |             strm.write('Version: 1.0\n') | 
					
						
							|  |  |  |  |         return 'CherryPy' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_dist_name_found_as_any_case(self): | 
					
						
							| 
									
										
										
										
											2021-04-02 12:35:32 -07:00
										 |  |  |  |         # Ensure the metadata loads when queried with any case. | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |         pkg_name = self.pkg_with_mixed_case(self.site_dir) | 
					
						
							|  |  |  |  |         assert version(pkg_name) == '1.0' | 
					
						
							|  |  |  |  |         assert version(pkg_name.lower()) == '1.0' | 
					
						
							|  |  |  |  |         assert version(pkg_name.upper()) == '1.0' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | class NonASCIITests(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase): | 
					
						
							|  |  |  |  |     @staticmethod | 
					
						
							|  |  |  |  |     def pkg_with_non_ascii_description(site_dir): | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         Create minimal metadata for a package with non-ASCII in | 
					
						
							|  |  |  |  |         the description. | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         metadata_dir = site_dir / 'portend.dist-info' | 
					
						
							|  |  |  |  |         metadata_dir.mkdir() | 
					
						
							|  |  |  |  |         metadata = metadata_dir / 'METADATA' | 
					
						
							|  |  |  |  |         with metadata.open('w', encoding='utf-8') as fp: | 
					
						
							| 
									
										
										
										
											2021-05-02 17:03:40 -04:00
										 |  |  |  |             fp.write('Description: pôrˈtend') | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |         return 'portend' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     @staticmethod | 
					
						
							|  |  |  |  |     def pkg_with_non_ascii_description_egg_info(site_dir): | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         Create minimal metadata for an egg-info package with | 
					
						
							|  |  |  |  |         non-ASCII in the description. | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         metadata_dir = site_dir / 'portend.dist-info' | 
					
						
							|  |  |  |  |         metadata_dir.mkdir() | 
					
						
							|  |  |  |  |         metadata = metadata_dir / 'METADATA' | 
					
						
							|  |  |  |  |         with metadata.open('w', encoding='utf-8') as fp: | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |             fp.write( | 
					
						
							|  |  |  |  |                 textwrap.dedent( | 
					
						
							|  |  |  |  |                     """
 | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |                 Name: portend | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 pôrˈtend | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |                 """
 | 
					
						
							| 
									
										
										
										
											2021-05-02 17:03:40 -04:00
										 |  |  |  |                 ).strip() | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |             ) | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |         return 'portend' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_metadata_loads(self): | 
					
						
							|  |  |  |  |         pkg_name = self.pkg_with_non_ascii_description(self.site_dir) | 
					
						
							|  |  |  |  |         meta = metadata(pkg_name) | 
					
						
							|  |  |  |  |         assert meta['Description'] == 'pôrˈtend' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_metadata_loads_egg_info(self): | 
					
						
							|  |  |  |  |         pkg_name = self.pkg_with_non_ascii_description_egg_info(self.site_dir) | 
					
						
							|  |  |  |  |         meta = metadata(pkg_name) | 
					
						
							| 
									
										
										
										
											2021-05-02 17:03:40 -04:00
										 |  |  |  |         assert meta['Description'] == 'pôrˈtend' | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  | class DiscoveryTests(fixtures.EggInfoPkg, fixtures.DistInfoPkg, unittest.TestCase): | 
					
						
							| 
									
										
										
										
											2019-05-24 19:59:01 -04:00
										 |  |  |  |     def test_package_discovery(self): | 
					
						
							|  |  |  |  |         dists = list(distributions()) | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |         assert all(isinstance(dist, Distribution) for dist in dists) | 
					
						
							|  |  |  |  |         assert any(dist.metadata['Name'] == 'egginfo-pkg' for dist in dists) | 
					
						
							|  |  |  |  |         assert any(dist.metadata['Name'] == 'distinfo-pkg' for dist in dists) | 
					
						
							| 
									
										
										
										
											2019-05-29 17:13:12 -07:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-10 14:53:31 +01:00
										 |  |  |  |     def test_invalid_usage(self): | 
					
						
							|  |  |  |  |         with self.assertRaises(ValueError): | 
					
						
							|  |  |  |  |             list(distributions(context='something', name='else')) | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-29 17:13:12 -07:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | class DirectoryTest(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase): | 
					
						
							| 
									
										
										
										
											2019-07-28 14:59:24 -04:00
										 |  |  |  |     def test_egg_info(self): | 
					
						
							| 
									
										
										
										
											2019-05-29 17:13:12 -07:00
										 |  |  |  |         # make an `EGG-INFO` directory that's unrelated | 
					
						
							|  |  |  |  |         self.site_dir.joinpath('EGG-INFO').mkdir() | 
					
						
							|  |  |  |  |         # used to crash with `IsADirectoryError` | 
					
						
							| 
									
										
										
										
											2019-07-28 14:59:24 -04:00
										 |  |  |  |         with self.assertRaises(PackageNotFoundError): | 
					
						
							|  |  |  |  |             version('unknown-package') | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_egg(self): | 
					
						
							|  |  |  |  |         egg = self.site_dir.joinpath('foo-3.6.egg') | 
					
						
							|  |  |  |  |         egg.mkdir() | 
					
						
							|  |  |  |  |         with self.add_sys_path(egg): | 
					
						
							|  |  |  |  |             with self.assertRaises(PackageNotFoundError): | 
					
						
							|  |  |  |  |                 version('foo') | 
					
						
							| 
									
										
										
										
											2019-12-10 20:05:10 -05:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-11 21:58:47 -05:00
										 |  |  |  | class MissingSysPath(fixtures.OnSysPath, unittest.TestCase): | 
					
						
							|  |  |  |  |     site_dir = '/does-not-exist' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_discovery(self): | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         Discovering distributions should succeed even if | 
					
						
							|  |  |  |  |         there is an invalid path on sys.path. | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         importlib.metadata.distributions() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | class InaccessibleSysPath(fixtures.OnSysPath, ffs.TestCase): | 
					
						
							|  |  |  |  |     site_dir = '/access-denied' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def setUp(self): | 
					
						
							| 
									
										
										
										
											2021-12-16 15:49:42 -05:00
										 |  |  |  |         super().setUp() | 
					
						
							| 
									
										
										
										
											2020-02-11 21:58:47 -05:00
										 |  |  |  |         self.setUpPyfakefs() | 
					
						
							|  |  |  |  |         self.fs.create_dir(self.site_dir, perm_bits=000) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_discovery(self): | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         Discovering distributions should succeed even if | 
					
						
							|  |  |  |  |         there is an invalid path on sys.path. | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         list(importlib.metadata.distributions()) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-10 20:05:10 -05:00
										 |  |  |  | class TestEntryPoints(unittest.TestCase): | 
					
						
							|  |  |  |  |     def __init__(self, *args): | 
					
						
							| 
									
										
										
										
											2021-12-16 15:49:42 -05:00
										 |  |  |  |         super().__init__(*args) | 
					
						
							|  |  |  |  |         self.ep = importlib.metadata.EntryPoint( | 
					
						
							|  |  |  |  |             name='name', value='value', group='group' | 
					
						
							|  |  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2019-12-10 20:05:10 -05:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_entry_point_pickleable(self): | 
					
						
							|  |  |  |  |         revived = pickle.loads(pickle.dumps(self.ep)) | 
					
						
							|  |  |  |  |         assert revived == self.ep | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-16 15:49:42 -05:00
										 |  |  |  |     def test_positional_args(self): | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         Capture legacy (namedtuple) construction, discouraged. | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         EntryPoint('name', 'value', 'group') | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-10 20:05:10 -05:00
										 |  |  |  |     def test_immutable(self): | 
					
						
							|  |  |  |  |         """EntryPoints should be immutable""" | 
					
						
							|  |  |  |  |         with self.assertRaises(AttributeError): | 
					
						
							|  |  |  |  |             self.ep.name = 'badactor' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_repr(self): | 
					
						
							|  |  |  |  |         assert 'EntryPoint' in repr(self.ep) | 
					
						
							|  |  |  |  |         assert 'name=' in repr(self.ep) | 
					
						
							|  |  |  |  |         assert "'name'" in repr(self.ep) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_hashable(self): | 
					
						
							| 
									
										
										
										
											2021-04-02 12:35:32 -07:00
										 |  |  |  |         # EntryPoints should be hashable. | 
					
						
							| 
									
										
										
										
											2019-12-10 20:05:10 -05:00
										 |  |  |  |         hash(self.ep) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_json_dump(self): | 
					
						
							| 
									
										
										
										
											2021-04-02 12:35:32 -07:00
										 |  |  |  |         # json should not expect to be able to dump an EntryPoint. | 
					
						
							| 
									
										
										
										
											2019-12-10 20:05:10 -05:00
										 |  |  |  |         with self.assertRaises(Exception): | 
					
						
							| 
									
										
										
										
											2021-03-13 11:31:45 -05:00
										 |  |  |  |             with warnings.catch_warnings(record=True): | 
					
						
							|  |  |  |  |                 json.dumps(self.ep) | 
					
						
							| 
									
										
										
										
											2020-06-05 16:34:16 -04:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_module(self): | 
					
						
							|  |  |  |  |         assert self.ep.module == 'value' | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_attr(self): | 
					
						
							|  |  |  |  |         assert self.ep.attr is None | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |     def test_sortable(self): | 
					
						
							| 
									
										
										
										
											2021-04-02 12:35:32 -07:00
										 |  |  |  |         # EntryPoint objects are sortable, but result is undefined. | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |         sorted( | 
					
						
							|  |  |  |  |             [ | 
					
						
							| 
									
										
										
										
											2021-12-16 15:49:42 -05:00
										 |  |  |  |                 EntryPoint(name='b', value='val', group='group'), | 
					
						
							|  |  |  |  |                 EntryPoint(name='a', value='val', group='group'), | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |             ] | 
					
						
							|  |  |  |  |         ) | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-05 16:34:16 -04:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-07 10:57:45 -04:00
										 |  |  |  | class FileSystem( | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |     fixtures.OnSysPath, fixtures.SiteDir, fixtures.FileBuilder, unittest.TestCase | 
					
						
							|  |  |  |  | ): | 
					
						
							| 
									
										
										
										
											2020-06-05 16:34:16 -04:00
										 |  |  |  |     def test_unicode_dir_on_sys_path(self): | 
					
						
							| 
									
										
										
										
											2021-04-02 12:35:32 -07:00
										 |  |  |  |         # Ensure a Unicode subdirectory of a directory on sys.path | 
					
						
							|  |  |  |  |         # does not crash. | 
					
						
							| 
									
										
										
										
											2020-06-07 10:57:45 -04:00
										 |  |  |  |         fixtures.build_files( | 
					
						
							|  |  |  |  |             {self.unicode_filename(): {}}, | 
					
						
							|  |  |  |  |             prefix=self.site_dir, | 
					
						
							| 
									
										
										
										
											2020-12-31 12:56:43 -05:00
										 |  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2020-06-05 16:34:16 -04:00
										 |  |  |  |         list(distributions()) | 
					
						
							| 
									
										
										
										
											2021-12-16 15:49:42 -05:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | class PackagesDistributionsPrebuiltTest(fixtures.ZipFixtures, unittest.TestCase): | 
					
						
							|  |  |  |  |     def test_packages_distributions_example(self): | 
					
						
							|  |  |  |  |         self._fixture_on_path('example-21.12-py3-none-any.whl') | 
					
						
							|  |  |  |  |         assert packages_distributions()['example'] == ['example'] | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     def test_packages_distributions_example2(self): | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         Test packages_distributions on a wheel built | 
					
						
							|  |  |  |  |         by trampolim. | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         self._fixture_on_path('example2-1.0.0-py3-none-any.whl') | 
					
						
							|  |  |  |  |         assert packages_distributions()['example2'] == ['example2'] | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | class PackagesDistributionsTest( | 
					
						
							|  |  |  |  |     fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase | 
					
						
							|  |  |  |  | ): | 
					
						
							|  |  |  |  |     def test_packages_distributions_neither_toplevel_nor_files(self): | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         Test a package built without 'top-level.txt' or a file list. | 
					
						
							|  |  |  |  |         """
 | 
					
						
							|  |  |  |  |         fixtures.build_files( | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 'trim_example-1.0.0.dist-info': { | 
					
						
							|  |  |  |  |                     'METADATA': """
 | 
					
						
							|  |  |  |  |                 Name: trim_example | 
					
						
							|  |  |  |  |                 Version: 1.0.0 | 
					
						
							|  |  |  |  |                 """,
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             }, | 
					
						
							|  |  |  |  |             prefix=self.site_dir, | 
					
						
							|  |  |  |  |         ) | 
					
						
							|  |  |  |  |         packages_distributions() |