From fb67438a23aef1ed781dce79b7ce20f346e50093 Mon Sep 17 00:00:00 2001 From: Tim Head Date: Sat, 25 Jan 2020 18:56:57 +0100 Subject: [PATCH 1/2] Explicitly disable the new --user default in pip --- integration-tests/test_install.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/integration-tests/test_install.py b/integration-tests/test_install.py index d3aa712..14f2a56 100644 --- a/integration-tests/test_install.py +++ b/integration-tests/test_install.py @@ -123,6 +123,7 @@ def test_installer_log_readable(): assert file_stat.st_uid == 0 assert file_stat.st_mode == 0o100500 + @pytest.mark.parametrize("group", [ADMIN_GROUP, USER_GROUP]) def test_user_env_readable(group): # every file in user env should be readable by everyone @@ -163,8 +164,15 @@ def test_pip_install(group, allowed): python = os.path.join(USER_PREFIX, "bin", "python") with context: + # we explicitly add `--no-user` here even though a real user wouldn't + # With this test we want to check that a user can't install to the + # global site-packages directory. In new versions of pip the default + # behaviour is to install to a user location when a global install + # isn't possible. By using --no-user we disable this behaviour and + # get a failure if the user can't install to the global site. Which is + # what we wanted to test for here. subprocess.check_call( - [python, "-m", "pip", "install", "--ignore-installed", "--no-deps", "flit"], + [python, "-m", "pip", "install", "--no-user", "--ignore-installed", "--no-deps", "flit"], preexec_fn=partial(setgroup, group), ) if allowed: @@ -215,4 +223,4 @@ def test_symlinks(): """ Test we symlink tljh-config to /usr/local/bin """ - assert os.path.exists('/usr/bin/tljh-config') \ No newline at end of file + assert os.path.exists('/usr/bin/tljh-config') From aa2222cd085b3b4ca37761d35e97a48b956e67dd Mon Sep 17 00:00:00 2001 From: Tim Head Date: Sat, 25 Jan 2020 20:54:10 +0100 Subject: [PATCH 2/2] Fix one more test --- integration-tests/test_install.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration-tests/test_install.py b/integration-tests/test_install.py index 14f2a56..58f2815 100644 --- a/integration-tests/test_install.py +++ b/integration-tests/test_install.py @@ -207,6 +207,7 @@ def test_pip_upgrade(group, allowed): "-m", "pip", "install", + "--no-user", "--ignore-installed", "--no-deps", "testpath==0.3.0", @@ -219,6 +220,7 @@ def test_pip_upgrade(group, allowed): preexec_fn=partial(setgroup, group), ) + def test_symlinks(): """ Test we symlink tljh-config to /usr/local/bin