From bcb4009688204a578d0e66e049c2a46ceba60d13 Mon Sep 17 00:00:00 2001 From: Devesh Kumar Singh Date: Sat, 28 Mar 2020 02:14:29 +0530 Subject: [PATCH] Add a test case for missing easy-install.pth fix --- tests/functional/test_uninstall.py | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/functional/test_uninstall.py b/tests/functional/test_uninstall.py index 04d8550f3..88ec0c687 100644 --- a/tests/functional/test_uninstall.py +++ b/tests/functional/test_uninstall.py @@ -553,6 +553,42 @@ def test_uninstall_editable_and_pip_install(script, data): assert "FSPkg" not in {p["name"] for p in json.loads(list_result2.stdout)} +def test_uninstall_editable_and_pip_install_easy_install_remove(script, data): + """Try uninstall after pip install -e after pip install + and removing easy-install.pth""" + # SETUPTOOLS_SYS_PATH_TECHNIQUE=raw removes the assumption that `-e` + # installs are always higher priority than regular installs. + # This becomes the default behavior in setuptools 25. + script.environ['SETUPTOOLS_SYS_PATH_TECHNIQUE'] = 'raw' + + # Rename easy-install.pth to pip-test.pth + easy_install_pth = join(script.site_packages_path, 'easy-install.pth') + pip_test_pth = join(script.site_packages_path, 'pip-test.pth') + os.rename(easy_install_pth, pip_test_pth) + + # Install FSPkg + pkg_path = data.packages.joinpath("FSPkg") + script.pip('install', '-e', '.', + expect_stderr=True, cwd=pkg_path) + + # Rename easy-install.pth to pip-test-fspkg.pth + pip_test_fspkg_pth = join(script.site_packages_path, 'pip-test-fspkg.pth') + os.rename(easy_install_pth, pip_test_fspkg_pth) + + # Confirm that FSPkg is installed + list_result = script.pip('list', '--format=json') + assert {"name": "FSPkg", "version": "0.1.dev0"} \ + in json.loads(list_result.stdout) + + # Uninstall will fail with given warning + uninstall = script.pip('uninstall', 'FSPkg', '-y') + assert "Cannot remove entries from nonexistent file" in uninstall.stderr + + # Cleanup pth files + os.remove(pip_test_fspkg_pth) + os.rename(pip_test_pth, easy_install_pth) + + def test_uninstall_ignores_missing_packages(script, data): """Uninstall of a non existent package prints a warning and exits cleanly """