2013-11-30 02:15:50 +01:00
|
|
|
"""
|
|
|
|
tests specific to uninstalling --user installs
|
|
|
|
"""
|
2017-10-06 21:51:42 +02:00
|
|
|
from os.path import isdir, isfile, normcase
|
2013-11-30 02:15:50 +01:00
|
|
|
|
2017-05-16 12:16:30 +02:00
|
|
|
import pytest
|
2017-06-13 14:17:00 +02:00
|
|
|
|
2013-11-30 02:15:50 +01:00
|
|
|
from tests.functional.test_install_user import _patch_dist_in_site_packages
|
2021-09-13 00:31:12 +02:00
|
|
|
from tests.lib import PipTestEnvironment, TestData, assert_all_changes
|
|
|
|
from tests.lib.venv import VirtualEnvironment
|
2022-10-27 04:36:46 +02:00
|
|
|
from tests.lib.wheel import make_wheel
|
2013-11-30 02:15:50 +01:00
|
|
|
|
|
|
|
|
2022-10-27 15:34:17 +02:00
|
|
|
@pytest.mark.usefixtures("enable_user_site")
|
2013-11-30 02:15:50 +01:00
|
|
|
class Tests_UninstallUserSite:
|
2015-01-15 00:53:15 +01:00
|
|
|
@pytest.mark.network
|
2021-09-13 00:31:12 +02:00
|
|
|
def test_uninstall_from_usersite(self, script: PipTestEnvironment) -> None:
|
2013-11-30 02:15:50 +01:00
|
|
|
"""
|
|
|
|
Test uninstall from usersite
|
|
|
|
"""
|
2021-08-08 00:23:54 +02:00
|
|
|
result1 = script.pip("install", "--user", "INITools==0.3")
|
|
|
|
result2 = script.pip("uninstall", "-y", "INITools")
|
|
|
|
assert_all_changes(result1, result2, [script.venv / "build", "cache"])
|
2013-11-30 02:15:50 +01:00
|
|
|
|
2021-09-13 00:31:12 +02:00
|
|
|
def test_uninstall_from_usersite_with_dist_in_global_site(
|
|
|
|
self, virtualenv: VirtualEnvironment, script: PipTestEnvironment
|
|
|
|
) -> None:
|
2013-11-30 02:15:50 +01:00
|
|
|
"""
|
|
|
|
Test uninstall from usersite (with same dist in global site)
|
|
|
|
"""
|
2022-10-27 04:36:46 +02:00
|
|
|
entry_points_txt = "[console_scripts]\nscript = pkg:func"
|
|
|
|
make_wheel(
|
|
|
|
"pkg",
|
|
|
|
"0.1",
|
|
|
|
extra_metadata_files={"entry_points.txt": entry_points_txt},
|
|
|
|
).save_to_dir(script.scratch_path)
|
|
|
|
make_wheel(
|
|
|
|
"pkg",
|
|
|
|
"0.1.1",
|
|
|
|
extra_metadata_files={"entry_points.txt": entry_points_txt},
|
|
|
|
).save_to_dir(script.scratch_path)
|
|
|
|
|
2018-10-08 18:09:53 +02:00
|
|
|
_patch_dist_in_site_packages(virtualenv)
|
2013-11-30 02:15:50 +01:00
|
|
|
|
2022-10-27 04:36:46 +02:00
|
|
|
script.pip(
|
|
|
|
"install",
|
|
|
|
"--no-index",
|
|
|
|
"--find-links",
|
|
|
|
script.scratch_path,
|
|
|
|
"--no-warn-script-location",
|
|
|
|
"pkg==0.1",
|
|
|
|
)
|
2014-01-28 15:17:51 +01:00
|
|
|
|
2022-10-27 04:36:46 +02:00
|
|
|
result2 = script.pip(
|
|
|
|
"install",
|
|
|
|
"--no-index",
|
|
|
|
"--find-links",
|
|
|
|
script.scratch_path,
|
|
|
|
"--no-warn-script-location",
|
|
|
|
"--user",
|
|
|
|
"pkg==0.1.1",
|
2021-08-08 00:23:54 +02:00
|
|
|
)
|
2022-10-27 04:36:46 +02:00
|
|
|
result3 = script.pip("uninstall", "-vy", "pkg")
|
2013-11-30 02:15:50 +01:00
|
|
|
|
|
|
|
# uninstall console is mentioning user scripts, but not global scripts
|
2017-10-06 21:51:42 +02:00
|
|
|
assert normcase(script.user_bin_path) in result3.stdout, str(result3)
|
|
|
|
assert normcase(script.bin_path) not in result3.stdout, str(result3)
|
2013-11-30 02:15:50 +01:00
|
|
|
|
|
|
|
# uninstall worked
|
2021-08-08 00:23:54 +02:00
|
|
|
assert_all_changes(result2, result3, [script.venv / "build", "cache"])
|
2013-11-30 02:15:50 +01:00
|
|
|
|
|
|
|
# site still has 0.2 (can't look in result1; have to check)
|
2022-10-27 04:36:46 +02:00
|
|
|
dist_info_folder = script.base_path / script.site_packages / "pkg-0.1.dist-info"
|
|
|
|
assert isdir(dist_info_folder)
|
2013-11-30 02:15:50 +01:00
|
|
|
|
2021-09-13 00:31:12 +02:00
|
|
|
def test_uninstall_editable_from_usersite(
|
|
|
|
self, script: PipTestEnvironment, data: TestData
|
|
|
|
) -> None:
|
2013-11-30 02:15:50 +01:00
|
|
|
"""
|
|
|
|
Test uninstall editable local user install
|
|
|
|
"""
|
2019-08-17 03:34:17 +02:00
|
|
|
assert script.user_site_path.exists()
|
2013-11-30 02:15:50 +01:00
|
|
|
|
2014-03-26 23:24:19 +01:00
|
|
|
# install
|
2019-07-02 07:00:32 +02:00
|
|
|
to_install = data.packages.joinpath("FSPkg")
|
2021-08-08 00:23:54 +02:00
|
|
|
result1 = script.pip("install", "--user", "-e", to_install)
|
|
|
|
egg_link = script.user_site / "FSPkg.egg-link"
|
2020-06-02 14:08:55 +02:00
|
|
|
result1.did_create(egg_link)
|
2013-11-30 02:15:50 +01:00
|
|
|
|
2014-03-26 23:24:19 +01:00
|
|
|
# uninstall
|
2021-08-08 00:23:54 +02:00
|
|
|
result2 = script.pip("uninstall", "-y", "FSPkg")
|
2013-11-30 02:15:50 +01:00
|
|
|
assert not isfile(script.base_path / egg_link)
|
|
|
|
|
2014-01-28 15:17:51 +01:00
|
|
|
assert_all_changes(
|
|
|
|
result1,
|
|
|
|
result2,
|
2014-02-24 22:52:23 +01:00
|
|
|
[
|
2021-08-08 00:23:54 +02:00
|
|
|
script.venv / "build",
|
|
|
|
"cache",
|
|
|
|
script.user_site / "easy-install.pth",
|
|
|
|
],
|
2014-01-28 15:17:51 +01:00
|
|
|
)
|