Skip to content

Commit 3b8c83d

Browse files
committed
Fix unit test setup to use BaseDistribution
1 parent a2a702c commit 3b8c83d

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

tests/unit/test_wheel.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from pip._internal.exceptions import InstallationError
1313
from pip._internal.locations import get_scheme
14+
from pip._internal.metadata import get_wheel_distribution
1415
from pip._internal.models.direct_url import (
1516
DIRECT_URL_METADATA_NAME,
1617
ArchiveInfo,
@@ -22,7 +23,6 @@
2223
from pip._internal.utils.compat import WINDOWS
2324
from pip._internal.utils.misc import hash_file
2425
from pip._internal.utils.unpacking import unpack_file
25-
from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel
2626
from tests.lib import DATA_DIR, assert_paths_equal
2727
from tests.lib.wheel import make_wheel
2828

@@ -84,7 +84,7 @@ def test_get_legacy_build_wheel_path__multiple_names(caplog):
8484
"進入點 = 套件.模組:函式",
8585
],
8686
)
87-
def test_get_entrypoints(console_scripts):
87+
def test_get_entrypoints(tmp_path, console_scripts):
8888
entry_points_text = """
8989
[console_scripts]
9090
{}
@@ -99,22 +99,18 @@ def test_get_entrypoints(console_scripts):
9999
extra_metadata_files={
100100
"entry_points.txt": entry_points_text,
101101
},
102-
).as_zipfile()
103-
distribution = pkg_resources_distribution_for_wheel(
104-
wheel_zip, "simple", "<in memory>"
105-
)
102+
).save_to_dir(tmp_path)
103+
distribution = get_wheel_distribution(wheel_zip, "simple")
106104

107105
assert wheel.get_entrypoints(distribution) == (
108106
dict([console_scripts.split(' = ')]),
109107
{},
110108
)
111109

112110

113-
def test_get_entrypoints_no_entrypoints():
114-
wheel_zip = make_wheel("simple", "0.1.0").as_zipfile()
115-
distribution = pkg_resources_distribution_for_wheel(
116-
wheel_zip, "simple", "<in memory>"
117-
)
111+
def test_get_entrypoints_no_entrypoints(tmp_path):
112+
wheel_zip = make_wheel("simple", "0.1.0").save_to_dir(tmp_path)
113+
distribution = get_wheel_distribution(wheel_zip, "simple")
118114

119115
console, gui = wheel.get_entrypoints(distribution)
120116
assert console == {}

0 commit comments

Comments
 (0)