From 58b7fa68a9bb0d740a90944cd5ed2627e1161cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Roussel?= Date: Wed, 6 Mar 2024 15:57:57 +0100 Subject: [PATCH] add test on pipx run --- tests/test_run.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_run.py b/tests/test_run.py index 7d93556641..98cd1dfe3b 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -11,7 +11,7 @@ import pipx.util from helpers import run_pipx_cli from package_info import PKG -from pipx import constants +from pipx import constants, shared_libs def test_help_text(pipx_temp_env, monkeypatch, capsys): @@ -299,6 +299,21 @@ def test_run_with_requirements_and_args(caplog, pipx_temp_env, tmp_path): assert out.read_text() == "2" +def test_pip_args_forwarded_to_shared_libs(pipx_ultra_temp_env, capsys, caplog): + # strategy: + # 1. start from an empty env to ensure the next command would trigger a shared lib update + assert shared_libs.shared_libs.needs_upgrade + # 2. install any package with --no-index + # and check that the shared library update phase fails + return_code = run_pipx_cli(["run", "pycowsay", "--verbose", "--pip-args='--no-index'"]) + assert "Upgrading shared libraries in" in caplog.text + + captured = capsys.readouterr() + assert return_code != 0 + assert "ERROR: Could not find a version that satisfies the requirement pip" in captured.err + assert "Failed to upgrade shared libraries" in caplog.text + + @mock.patch("os.execvpe", new=execvpe_mock) def test_run_with_invalid_requirement(capsys, pipx_temp_env, tmp_path): script = tmp_path / "test.py"