|
2 | 2 | tests specific to "pip install --user"
|
3 | 3 | """
|
4 | 4 | import os
|
| 5 | +import re |
5 | 6 | import textwrap
|
6 | 7 | from os.path import curdir, isdir, isfile
|
7 | 8 | from pathlib import Path
|
@@ -287,35 +288,45 @@ def test_install_user_conflict_in_globalsite_and_usersite(
|
287 | 288 | assert isdir(dist_info_folder)
|
288 | 289 | assert isdir(initools_folder)
|
289 | 290 |
|
290 |
| - @pytest.mark.network |
291 | 291 | def test_install_user_in_global_virtualenv_with_conflict_fails(
|
292 | 292 | self, script: PipTestEnvironment
|
293 | 293 | ) -> None:
|
294 | 294 | """
|
295 | 295 | Test user install in --system-site-packages virtualenv with conflict in
|
296 | 296 | site fails.
|
297 | 297 | """
|
| 298 | + create_basic_wheel_for_package(script, "pkg", "0.1") |
| 299 | + create_basic_wheel_for_package(script, "pkg", "0.2") |
298 | 300 |
|
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 | + ) |
300 | 308 |
|
301 | 309 | result2 = script.pip(
|
302 | 310 | "install",
|
| 311 | + "--no-index", |
| 312 | + "--find-links", |
| 313 | + script.scratch_path, |
303 | 314 | "--user",
|
304 |
| - "INITools==0.1", |
| 315 | + "pkg==0.1", |
305 | 316 | expect_error=True,
|
306 | 317 | )
|
307 | 318 | resultp = script.run(
|
308 | 319 | "python",
|
309 | 320 | "-c",
|
310 | 321 | "import pkg_resources; print(pkg_resources.get_distribution"
|
311 |
| - "('initools').location)", |
| 322 | + "('pkg').location)", |
312 | 323 | )
|
313 | 324 | 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$" |
321 | 329 | )
|
| 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