From 9dc7c80052a35af207afd07ded361b3b53140391 Mon Sep 17 00:00:00 2001 From: Daniel Meppiel <51440732+danielmeppiel@users.noreply.github.com> Date: Tue, 5 May 2026 05:44:22 +0200 Subject: [PATCH] tests: skip runtime factory tests when LLM not installed Four tests in test_runtime_factory.py assumed LLM is installed on the host system. In CI (and most dev environments), only Copilot/Codex may be present, causing spurious failures. Fix: add module-level skip markers that probe runtime availability at collection time. LLM-specific tests skip gracefully when 'llm' runtime is absent; runtime-agnostic tests remain unconditional. Also refactored test_get_available_runtimes_real_system to not assume LLM is present, and split the LLM-specific assertion into a separate skippable test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/unit/test_runtime_factory.py | 34 +++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tests/unit/test_runtime_factory.py b/tests/unit/test_runtime_factory.py index b5139a4b8..b9fe1396a 100644 --- a/tests/unit/test_runtime_factory.py +++ b/tests/unit/test_runtime_factory.py @@ -6,19 +6,35 @@ from apm_cli.runtime.factory import RuntimeFactory +_llm_available = RuntimeFactory.runtime_exists("llm") +_any_runtime_available = bool(RuntimeFactory.get_available_runtimes()) + +skip_no_llm = pytest.mark.skipif( + not _llm_available, reason="LLM runtime not installed on this system" +) +skip_no_runtime = pytest.mark.skipif( + not _any_runtime_available, reason="No runtime available on this system" +) + class TestRuntimeFactory: """Test Runtime Factory.""" def test_get_available_runtimes_real_system(self): - """Test getting available runtimes on real system (LLM should be available).""" + """Test getting available runtimes - returns a list (may be empty in CI).""" available = RuntimeFactory.get_available_runtimes() - # At least LLM should be available since it's installed - assert len(available) >= 1 - assert any(rt.get("name") == "llm" for rt in available) + assert isinstance(available, list) assert all(rt.get("available") for rt in available) + @skip_no_llm + def test_get_available_runtimes_includes_llm(self): + """Test that LLM appears in available runtimes when installed.""" + available = RuntimeFactory.get_available_runtimes() + + assert any(rt.get("name") == "llm" for rt in available) + + @skip_no_llm def test_get_runtime_by_name_llm_real(self): """Test getting LLM runtime by name (real system).""" runtime = RuntimeFactory.get_runtime_by_name("llm") @@ -31,14 +47,15 @@ def test_get_runtime_by_name_unknown(self): with pytest.raises(ValueError, match="Unknown runtime: unknown"): RuntimeFactory.get_runtime_by_name("unknown") + @skip_no_runtime def test_get_best_available_runtime_real(self): """Test getting best available runtime on real system.""" runtime = RuntimeFactory.get_best_available_runtime() assert runtime is not None - # Should be Copilot if available, otherwise Codex, otherwise LLM assert runtime.get_runtime_name() in ["copilot", "codex", "llm"] + @skip_no_llm def test_create_runtime_with_name_real(self): """Test creating runtime with specific name (real system).""" runtime = RuntimeFactory.create_runtime("llm") @@ -46,20 +63,21 @@ def test_create_runtime_with_name_real(self): assert runtime is not None assert runtime.get_runtime_name() == "llm" + @skip_no_runtime def test_create_runtime_auto_detect_real(self): """Test creating runtime with auto-detection (real system).""" runtime = RuntimeFactory.create_runtime() assert runtime is not None - # Should be Copilot if available, otherwise Codex, otherwise LLM assert runtime.get_runtime_name() in ["copilot", "codex", "llm"] + @skip_no_llm def test_runtime_exists_llm_true(self): - """Test runtime exists check for LLM - true.""" + """Test runtime exists check for LLM - true when installed.""" assert RuntimeFactory.runtime_exists("llm") is True def test_runtime_exists_false(self): - """Test runtime exists check - false.""" + """Test runtime exists check - false for unknown runtime.""" assert RuntimeFactory.runtime_exists("unknown") is False def test_runtime_exists_codex_depends_on_system(self):