[Test Improver] tests: skip runtime factory tests when LLM not installed#1139
[Test Improver] tests: skip runtime factory tests when LLM not installed#1139danielmeppiel wants to merge 2 commits into
Conversation
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>
There was a problem hiding this comment.
Pull request overview
This PR makes tests/unit/test_runtime_factory.py resilient to environments where the llm runtime (and/or any runtime) is not installed, by skipping runtime-dependent tests instead of failing unconditionally during CI and local runs.
Changes:
- Added module-level
pytest.mark.skipifmarkers to skip LLM-specific tests whenllmis unavailable, and skip auto-detect tests when no runtime is available. - Refactored
test_get_available_runtimes_real_systemto assert only environment-agnostic properties (returns a list). - Added a dedicated LLM-inclusion assertion test that is also skippable when LLM is not present.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_runtime_factory.py | Adds collection-time runtime availability detection and skip markers to avoid CI failures when optional runtimes are not installed. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
| _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" |
|
🤖 Test Improver here. This PR now has a merge conflict. More importantly, reviewing main's history shows that equivalent runtime-factory test fixes were incorporated into the codebase independently - All 9 runtime factory tests in main pass cleanly without this PR's changes. I'd recommend closing this PR as superseded. Happy to leave that decision to you. Note 🔒 Integrity filter blocked 19 itemsThe following items were blocked because they don't meet the GitHub integrity level.
To allow these resources, lower tools:
github:
min-integrity: approved # merged | approved | unapproved | none
|
🤖 Test Improver - automated AI assistant for test improvements.
Goal and Rationale
Four tests in
test_runtime_factory.pyhard-coded assumptions that thellmruntime is installed on the host system. In CI (and standard dev environments without thellmPython package), these tests fail unconditionally with:This creates noise in CI output and obscures real failures.
Approach
Added module-level skip markers that probe runtime availability at collection time using the factory's own
runtime_exists()method - so the logic is consistent with production code:test_get_runtime_by_name_llm_real,test_create_runtime_with_name_real,test_runtime_exists_llm_true) now skip gracefully when LLM is absenttest_get_available_runtimes_real_systemrefactored to be environment-agnostic (any list is valid)test_get_available_runtimes_includes_llmtest captures the LLM-specific assertion, also skippableget_best_available_runtimeandcreate_runtime(auto-detect) skip when no runtime at all is availableCoverage Impact
The tests still run and assert correctness when the runtime is present.
Trade-offs
Reproducibility
Test Status
test_runtime_factory.pytest_policy_status.pyare pre-existing (unrelated to this PR)