From f8d58256b74ad1b8909a4efd86bdcc4449f54ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Fri, 23 Aug 2019 23:11:12 +0200 Subject: [PATCH] Add failing test for symlink uninstall --- tests/functional/test_uninstall.py | 21 +++++++++++++++++++++ tests/lib/path.py | 10 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/tests/functional/test_uninstall.py b/tests/functional/test_uninstall.py index 128d66102..2e7330fee 100644 --- a/tests/functional/test_uninstall.py +++ b/tests/functional/test_uninstall.py @@ -458,6 +458,27 @@ def test_uninstall_wheel(script, data): assert_all_changes(result, result2, []) +@pytest.mark.skipif("sys.platform == 'win32'") +def test_uninstall_with_symlink(script, data, tmpdir): + """ + Test uninstalling a wheel, with an additional symlink + https://github.com/pypa/pip/issues/6892 + """ + package = data.packages.joinpath("simple.dist-0.1-py2.py3-none-any.whl") + script.pip('install', package, '--no-index') + symlink_target = tmpdir / "target" + symlink_target.mkdir() + symlink_source = script.site_packages / "symlink" + (script.base_path / symlink_source).symlink_to(symlink_target) + st_mode = symlink_target.stat().st_mode + distinfo_path = script.site_packages_path / 'simple.dist-0.1.dist-info' + record_path = distinfo_path / 'RECORD' + record_path.append_text("symlink,,\n") + uninstall_result = script.pip('uninstall', 'simple.dist', '-y') + assert symlink_source in uninstall_result.files_deleted + assert symlink_target.stat().st_mode == st_mode + + def test_uninstall_setuptools_develop_install(script, data): """Try uninstall after setup.py develop followed of setup.py install""" pkg_path = data.packages.joinpath("FSPkg") diff --git a/tests/lib/path.py b/tests/lib/path.py index cb2e6bda7..d54146868 100644 --- a/tests/lib/path.py +++ b/tests/lib/path.py @@ -203,9 +203,19 @@ class Path(_base): with open(self, "w") as fp: fp.write(content) + def append_text(self, content): + with open(self, "a") as fp: + fp.write(content) + def touch(self): with open(self, "a") as fp: path = fp.fileno() if os.utime in supports_fd else self os.utime(path, None) # times is not optional on Python 2.7 + def symlink_to(self, target): + os.symlink(target, self) + + def stat(self): + return os.stat(self) + curdir = Path(os.path.curdir)