Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 71e5ea2

Browse files
authored
Fix test coverage regression by updating import paths and test files (#12)
* Fix test coverage regression by using improved test files and fixing test assertions * Improve system_tools test coverage and fix import paths in test files
1 parent cb30443 commit 71e5ea2

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

scripts/tools_coverage.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ python -m pytest test_dir/improved/test_tree_tool.py test_dir/test_tree_tool_edg
3838

3939
# System tools
4040
echo "=== Running system_tools.py tests ==="
41-
python -m pytest test_dir/test_tools_basic.py -v --cov=src.cli_code.tools.system_tools --cov-append
41+
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
4242

4343
# Base tool class
4444
echo "=== Running base.py tests ==="

test_dir/test_system_tools.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""
2-
Tests for system tools.
2+
Tests for system_tools module to improve code coverage.
33
"""
4-
import subprocess
4+
import os
55
import pytest
66
from unittest.mock import patch, MagicMock
7+
import subprocess
78

89
# Direct import for coverage tracking
910
import src.cli_code.tools.system_tools
@@ -14,7 +15,7 @@ def test_bash_tool_init():
1415
"""Test BashTool initialization."""
1516
tool = BashTool()
1617
assert tool.name == "bash"
17-
assert tool.description == "Execute a bash command"
18+
assert "Execute a bash command" in tool.description
1819
assert isinstance(tool.BANNED_COMMANDS, list)
1920
assert len(tool.BANNED_COMMANDS) > 0
2021

@@ -79,7 +80,7 @@ def test_bash_tool_timeout(mock_popen):
7980

8081
# Execute command with short timeout
8182
tool = BashTool()
82-
result = tool.execute("sleep 10", timeout=1000) # 1 second timeout
83+
result = tool.execute("sleep 10", timeout=1) # 1 second timeout
8384

8485
# Verify timeout handling
8586
assert "Command timed out" in result

test_dir/test_tools_basic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
# Import necessary modules safely
1313
try:
14-
from cli_code.tools.base import BaseTool
15-
from cli_code.tools.file_tools import ViewTool, EditTool, GrepTool, GlobTool
16-
from cli_code.tools.quality_tools import _run_quality_command, LinterCheckerTool, FormatterTool
17-
from cli_code.tools.summarizer_tool import SummarizeCodeTool
18-
from cli_code.tools.system_tools import BashTool
19-
from cli_code.tools.task_complete_tool import TaskCompleteTool
20-
from cli_code.tools.tree_tool import TreeTool
14+
from src.cli_code.tools.base import BaseTool
15+
from src.cli_code.tools.file_tools import ViewTool, EditTool, GrepTool, GlobTool
16+
from src.cli_code.tools.quality_tools import _run_quality_command, LinterCheckerTool, FormatterTool
17+
from src.cli_code.tools.summarizer_tool import SummarizeCodeTool
18+
from src.cli_code.tools.system_tools import BashTool
19+
from src.cli_code.tools.task_complete_tool import TaskCompleteTool
20+
from src.cli_code.tools.tree_tool import TreeTool
2121
IMPORTS_AVAILABLE = True
2222
except ImportError:
2323
IMPORTS_AVAILABLE = False

0 commit comments

Comments
 (0)