Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/tools_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ python -m pytest test_dir/improved/test_tree_tool.py test_dir/test_tree_tool_edg

# System tools
echo "=== Running system_tools.py tests ==="
python -m pytest test_dir/test_tools_basic.py -v --cov=src.cli_code.tools.system_tools --cov-append
python -m pytest test_dir/test_system_tools.py test_dir/test_tools_basic.py::TestSystemTools -v --cov=src.cli_code.tools.system_tools --cov-append

# Base tool class
echo "=== Running base.py tests ==="
Expand Down
9 changes: 5 additions & 4 deletions test_dir/test_system_tools.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""
Tests for system tools.
Tests for system_tools module to improve code coverage.
"""
import subprocess
import os
import pytest
from unittest.mock import patch, MagicMock
import subprocess
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The subprocess module is imported twice. Remove the redundant import.


# Direct import for coverage tracking
import src.cli_code.tools.system_tools
Expand All @@ -14,7 +15,7 @@ def test_bash_tool_init():
"""Test BashTool initialization."""
tool = BashTool()
assert tool.name == "bash"
assert tool.description == "Execute a bash command"
assert "Execute a bash command" in tool.description
assert isinstance(tool.BANNED_COMMANDS, list)
assert len(tool.BANNED_COMMANDS) > 0

Expand Down Expand Up @@ -79,7 +80,7 @@ def test_bash_tool_timeout(mock_popen):

# Execute command with short timeout
tool = BashTool()
result = tool.execute("sleep 10", timeout=1000) # 1 second timeout
result = tool.execute("sleep 10", timeout=1) # 1 second timeout
Comment on lines 81 to +83
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The timeout is set to 1 second. Is this sufficient for all test environments? Consider making this configurable or increasing it if tests are failing intermittently due to timeouts.


# Verify timeout handling
assert "Command timed out" in result
Expand Down
14 changes: 7 additions & 7 deletions test_dir/test_tools_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

# Import necessary modules safely
try:
from cli_code.tools.base import BaseTool
from cli_code.tools.file_tools import ViewTool, EditTool, GrepTool, GlobTool
from cli_code.tools.quality_tools import _run_quality_command, LinterCheckerTool, FormatterTool
from cli_code.tools.summarizer_tool import SummarizeCodeTool
from cli_code.tools.system_tools import BashTool
from cli_code.tools.task_complete_tool import TaskCompleteTool
from cli_code.tools.tree_tool import TreeTool
from src.cli_code.tools.base import BaseTool
from src.cli_code.tools.file_tools import ViewTool, EditTool, GrepTool, GlobTool
from src.cli_code.tools.quality_tools import _run_quality_command, LinterCheckerTool, FormatterTool
from src.cli_code.tools.summarizer_tool import SummarizeCodeTool
from src.cli_code.tools.system_tools import BashTool
from src.cli_code.tools.task_complete_tool import TaskCompleteTool
from src.cli_code.tools.tree_tool import TreeTool
IMPORTS_AVAILABLE = True
except ImportError:
IMPORTS_AVAILABLE = False
Expand Down