From b734d6e30da55f5c80be8b6c1cb1f06c70c38c7f Mon Sep 17 00:00:00 2001 From: Min RK Date: Sun, 5 Nov 2017 16:36:16 +0100 Subject: [PATCH] test trailing-newline uninstall behavior --- tests/functional/test_uninstall.py | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/functional/test_uninstall.py b/tests/functional/test_uninstall.py index 609d28393..8ab346bf6 100644 --- a/tests/functional/test_uninstall.py +++ b/tests/functional/test_uninstall.py @@ -100,6 +100,39 @@ def test_uninstall_easy_install_after_import(script): ) +@pytest.mark.network +def test_uninstall_trailing_newline(script): + """ + Uninstall behaves appropriately if easy-install.pth + lacks a trailing newline + + """ + script.run('easy_install', 'INITools==0.2', expect_stderr=True) + script.run('easy_install', 'PyLogo', expect_stderr=True) + easy_install_pth = script.site_packages_path / 'easy-install.pth' + + # trim trailing newline from easy-install.pth + with open(easy_install_pth) as f: + pth_before = f.read() + + with open(easy_install_pth, 'w') as f: + f.write(pth_before.rstrip()) + + # uninstall initools + script.pip('uninstall', 'INITools', '-y') + with open(easy_install_pth) as f: + pth_after = f.read() + + # verify that only initools is removed + before_without_initools = [ + line for line in pth_before.splitlines() + if 'initools' not in line.lower() + ] + lines_after = pth_after.splitlines() + + assert lines_after == before_without_initools + + @pytest.mark.network def test_uninstall_namespace_package(script): """