Compare commits

...
Author SHA1 Message Date
praisonai-triage-agent[bot]andMervin Praison 31b57e4dc7 fix: restore cross-platform test coverage removed by over-broad skips
- Remove unconditional skip on test_get_runtime_descriptor_keeps_live_lock:
  get_runtime_descriptor(require_alive=True) has no loop/sleep and does not
  hang; the test is deterministic and passes.
- Stop skipping test_shell_enabled_runs_command via shutil.which("echo"):
  _run_shell_command uses shell=True so echo works via cmd.exe on Windows.
  Normalize the assertion (strip trailing \r) instead of dropping coverage.
- Tidy imports and trailing whitespace in test_custom_definitions.py.

Co-authored-by: Mervin Praison <[email protected]>
2026-08-19 12:34:25 +00:00
2 changed files with 6 additions and 8 deletions

No files matched your search

@@ -2,12 +2,13 @@
Tests for custom agent and command definitions discovery.
"""
import sys
import tempfile
from pathlib import Path
from unittest.mock import patch
import sys
import shutil
import pytest
from praisonai.cli.features.custom_definitions import (
BUILTIN_PRESETS,
SHELL_SUBSTITUTION_ENV,
@@ -223,12 +224,11 @@ class TestShellSubstitution:
with pytest.raises(ShellSubstitutionError):
TemplateInterpolator.interpolate(template)
@pytest.mark.skipif(not shutil.which("echo"), reason="echo command not available in PATH")
def test_shell_enabled_runs_command(self):
"""With allow_shell=True the command runs and stdout is inlined."""
template = "Output: !`echo hello world`"
result = TemplateInterpolator.interpolate(template, allow_shell=True)
assert result == "Output: hello world"
assert result.strip() == "Output: hello world"
@pytest.mark.skipif(sys.platform == "win32", reason="Unix commands not available on Windows")
def test_shell_runs_in_working_dir(self):
@@ -283,8 +283,7 @@ class TestShellSubstitution:
CustomDefinitionsDiscovery, '_find_project_dirs', return_value=[Path(tmpdir)]
), patch.dict("os.environ", {SHELL_SUBSTITUTION_ENV: "true"}):
result = interpolate_command_template("diff")
assert result.strip() == "Output: hi"
assert result.strip() == "Output: hi"
def test_frontmatter_allow_shell_enables(self):
"""allow_shell: true frontmatter enables substitution for that command."""
@@ -305,7 +304,7 @@ class TestShellSubstitution:
import os as _os
_os.environ.pop(SHELL_SUBSTITUTION_ENV, None)
result = interpolate_command_template("diff")
assert result.strip() == "Output: hey"
assert result.strip() == "Output: hey"
def test_default_command_disables_shell(self):
"""Without any gate, a !`cmd` command raises a clear error."""
@@ -67,7 +67,6 @@ def test_get_runtime_descriptor_removes_stale_lock():
assert not get_runtime_lock_path().exists()
@pytest.mark.skip(reason="Test hangs indefinitely - needs investigation and proper fix")
def test_get_runtime_descriptor_keeps_live_lock():
desc = RuntimeDescriptor(host="127.0.0.1", port=1, token="t", pid=os.getpid())
desc.write()