test: explicitly stub _pip_available in pip-path tests

CI's uv-managed Python does not have pip importable, so the runtime
falls back to uv pip. Four tests that verify the python -m pip path
were failing because _pip_available() returned False in CI.

Monkeypatch _pip_available to True in tests that intentionally verify
the pip code path, so they pass regardless of the CI Python
environment.
This commit is contained in:
axelray-dev 2026-06-03 10:32:42 +08:00 committed by Xubin Ren
parent a37e58a29e
commit 6d827efb0e

View File

@ -283,6 +283,7 @@ def test_install_dispatches_safe_pip_and_installs_skill(
return subprocess.CompletedProcess(argv, 0, stdout="ok", stderr="")
monkeypatch.setattr(manager, "_run_argv", fake_run)
monkeypatch.setattr(manager, "_pip_available", staticmethod(lambda: True))
monkeypatch.setattr(
manager,
"_fetch_skill_content",
@ -572,6 +573,7 @@ def test_uninstall_uses_safe_python_m_pip_uninstall_command(
return subprocess.CompletedProcess(argv, 0, stdout="ok", stderr="")
monkeypatch.setattr(manager, "_run_argv", fake_run)
monkeypatch.setattr(manager, "_pip_available", staticmethod(lambda: True))
payload = manager.uninstall("suno")
@ -599,6 +601,7 @@ def test_uninstall_uses_recorded_pip_distribution(
return subprocess.CompletedProcess(argv, 0, stdout="ok", stderr="")
monkeypatch.setattr(manager, "_run_argv", fake_run)
monkeypatch.setattr(manager, "_pip_available", staticmethod(lambda: True))
payload = manager.uninstall("gimp")
@ -621,6 +624,7 @@ def test_uninstall_keeps_state_when_entry_point_still_available(
"_run_argv",
lambda argv, *, timeout: subprocess.CompletedProcess(argv, 0, stdout="ok", stderr=""),
)
monkeypatch.setattr(manager, "_pip_available", staticmethod(lambda: True))
monkeypatch.setattr(
"nanobot.apps.cli.service.shutil.which",
lambda command: "/usr/local/bin/cli-anything-gimp" if command == "cli-anything-gimp" else None,