Skip to content

Commit 9886746

Browse files
committed
Fix test failure due to metadata backend switch
We switched the metadata backend to importlib.metadata for Python 3.11 onwards, which normalizes path differently.
1 parent 0732e6e commit 9886746

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

tests/functional/test_install_user.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,35 +287,41 @@ def test_install_user_conflict_in_globalsite_and_usersite(
287287
assert isdir(dist_info_folder)
288288
assert isdir(initools_folder)
289289

290-
@pytest.mark.network
291290
def test_install_user_in_global_virtualenv_with_conflict_fails(
292291
self, script: PipTestEnvironment
293292
) -> None:
294293
"""
295294
Test user install in --system-site-packages virtualenv with conflict in
296295
site fails.
297296
"""
297+
create_basic_wheel_for_package(script, "pkg", "0.1")
298+
create_basic_wheel_for_package(script, "pkg", "0.2")
298299

299-
script.pip("install", "INITools==0.2")
300+
script.pip(
301+
"install",
302+
"--no-index",
303+
"--find-links",
304+
script.scratch_path,
305+
"pkg==0.2",
306+
)
300307

301308
result2 = script.pip(
302309
"install",
310+
"--no-index",
311+
"--find-links",
312+
script.scratch_path,
303313
"--user",
304-
"INITools==0.1",
314+
"pkg==0.1",
305315
expect_error=True,
306316
)
307317
resultp = script.run(
308318
"python",
309319
"-c",
310-
"import pkg_resources; print(pkg_resources.get_distribution"
311-
"('initools').location)",
320+
"from pip._internal.metadata import get_default_environment; "
321+
"print(get_default_environment().get_distribution('pkg').location)",
312322
)
313323
dist_location = resultp.stdout.strip()
314324
assert (
315-
"Will not install to the user site because it will lack sys.path "
316-
"precedence to {name} in {location}".format(
317-
name="INITools",
318-
location=dist_location,
319-
)
320-
in result2.stderr
321-
)
325+
f"Will not install to the user site because it will lack sys.path "
326+
f"precedence to pkg in {dist_location}"
327+
) in result2.stderr

0 commit comments

Comments
 (0)