|
8 | 8 | from importlib_metadata import ( |
9 | 9 | MetadataPathFinder, |
10 | 10 | _compat, |
11 | | - distribution, |
12 | 11 | distributions, |
13 | | - entry_points, |
14 | | - metadata, |
15 | 12 | version, |
16 | 13 | ) |
17 | 14 |
|
@@ -48,68 +45,6 @@ def __getattribute__(self, name): |
48 | 45 | _compat.disable_stdlib_finder() |
49 | 46 |
|
50 | 47 |
|
51 | | -class OldStdlibFinderTests(fixtures.DistInfoPkgOffPath, unittest.TestCase): |
52 | | - def setUp(self): |
53 | | - python_version = sys.version_info[:2] |
54 | | - if python_version < (3, 8) or python_version > (3, 9): |
55 | | - self.skipTest("Tests specific for Python 3.8/3.9") |
56 | | - super().setUp() |
57 | | - |
58 | | - def _meta_path_finder(self): |
59 | | - from importlib.metadata import ( |
60 | | - Distribution, |
61 | | - DistributionFinder, |
62 | | - PathDistribution, |
63 | | - ) |
64 | | - from importlib.util import spec_from_file_location |
65 | | - |
66 | | - path = pathlib.Path(self.site_dir) |
67 | | - |
68 | | - class CustomDistribution(Distribution): |
69 | | - def __init__(self, name, path): |
70 | | - self.name = name |
71 | | - self._path_distribution = PathDistribution(path) |
72 | | - |
73 | | - def read_text(self, filename): |
74 | | - return self._path_distribution.read_text(filename) |
75 | | - |
76 | | - def locate_file(self, path): |
77 | | - return self._path_distribution.locate_file(path) |
78 | | - |
79 | | - class CustomFinder: |
80 | | - @classmethod |
81 | | - def find_spec(cls, fullname, _path=None, _target=None): |
82 | | - candidate = pathlib.Path(path, *fullname.split(".")).with_suffix(".py") |
83 | | - if candidate.exists(): |
84 | | - return spec_from_file_location(fullname, candidate) |
85 | | - |
86 | | - @classmethod |
87 | | - def find_distributions(self, context=DistributionFinder.Context()): |
88 | | - for dist_info in path.glob("*.dist-info"): |
89 | | - yield PathDistribution(dist_info) |
90 | | - name, _, _ = str(dist_info).partition("-") |
91 | | - yield CustomDistribution(name + "_custom", dist_info) |
92 | | - |
93 | | - return CustomFinder |
94 | | - |
95 | | - def test_compatibility_with_old_stdlib_path_distribution(self): |
96 | | - """ |
97 | | - Given a custom finder that uses Python 3.8/3.9 importlib.metadata is installed, |
98 | | - when importlib_metadata functions are called, there should be no exceptions. |
99 | | - Ref python/importlib_metadata#396. |
100 | | - """ |
101 | | - self.fixtures.enter_context(fixtures.install_finder(self._meta_path_finder())) |
102 | | - |
103 | | - assert list(distributions()) |
104 | | - assert distribution("distinfo_pkg") |
105 | | - assert distribution("distinfo_pkg_custom") |
106 | | - assert version("distinfo_pkg") > "0" |
107 | | - assert version("distinfo_pkg_custom") > "0" |
108 | | - assert list(metadata("distinfo_pkg")) |
109 | | - assert list(metadata("distinfo_pkg_custom")) |
110 | | - assert list(entry_points(group="entries")) |
111 | | - |
112 | | - |
113 | 48 | class DistSearch(unittest.TestCase): |
114 | 49 | def test_search_dist_dirs(self): |
115 | 50 | """ |
|
0 commit comments