Skip to content

Commit

Permalink
add test on pipx run
Browse files Browse the repository at this point in the history
  • Loading branch information
Grégoire Roussel committed Mar 6, 2024
1 parent d88d5f1 commit 58b7fa6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 58b7fa6

Please sign in to comment.