agent-Specialization/test/test_tool_result_formatter.py

30 lines
975 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import unittest
from utils.tool_result_formatter import format_tool_result_for_context
class ToolResultFormatterTest(unittest.TestCase):
def test_read_skill_formats_full_read_content_like_read_file(self):
result = {
"success": True,
"type": "read",
"path": "skills/frontend-design/SKILL.md",
"max_chars": 50000,
"truncated": False,
"content": "# Skill\nFull content",
"line_start": 1,
"line_end": 2,
"total_lines": 2,
"message": "已读取 skills/frontend-design/SKILL.md 的内容(行 1~2",
}
formatted = format_tool_result_for_context("read_skill", result)
self.assertIn("读取 skills/frontend-design/SKILL.md 行 1~2", formatted)
self.assertIn("```\n# Skill\nFull content\n```", formatted)
self.assertNotEqual(result["message"], formatted)
if __name__ == "__main__":
unittest.main()