Skip to content

Commit 0002b64

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 0002b64

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

tests/functional/test_install_user.py

+22-11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
tests specific to "pip install --user"
33
"""
44
import os
5+
import re
56
import textwrap
67
from os.path import curdir, isdir, isfile
78
from pathlib import Path
@@ -287,35 +288,45 @@ def test_install_user_conflict_in_globalsite_and_usersite(
287288
assert isdir(dist_info_folder)
288289
assert isdir(initools_folder)
289290

290-
@pytest.mark.network
291291
def test_install_user_in_global_virtualenv_with_conflict_fails(
292292
self, script: PipTestEnvironment
293293
) -> None:
294294
"""
295295
Test user install in --system-site-packages virtualenv with conflict in
296296
site fails.
297297
"""
298+
create_basic_wheel_for_package(script, "pkg", "0.1")
299+
create_basic_wheel_for_package(script, "pkg", "0.2")
298300

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

301309
result2 = script.pip(
302310
"install",
311+
"--no-index",
312+
"--find-links",
313+
script.scratch_path,
303314
"--user",
304-
"INITools==0.1",
315+
"pkg==0.1",
305316
expect_error=True,
306317
)
307318
resultp = script.run(
308319
"python",
309320
"-c",
310321
"import pkg_resources; print(pkg_resources.get_distribution"
311-
"('initools').location)",
322+
"('pkg').location)",
312323
)
313324
dist_location = resultp.stdout.strip()
314-
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
325+
326+
message_pattern = re.compile(
327+
r".*Will not install to the user site because it will lack "
328+
r"sys\.path precedence to pkg in (.+)\n$"
321329
)
330+
match = message_pattern.match(result2.stderr)
331+
assert match is not None
332+
assert os.path.samefile(match.group(1), dist_location)

0 commit comments

Comments
 (0)