test trailing-newline uninstall behavior
@@ -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):
"""
