style: Apply linter fixes

This commit is contained in:
Paul Gauthier (aider) 2025-03-31 10:33:00 +13:00
parent 605d8fe59a
commit a07f312089

View file

@ -446,29 +446,30 @@ class TestInputOutputMultilineMode(unittest.TestCase):
self.assertEqual(ensure_hash_prefix("1234567"), "1234567") # Wrong length self.assertEqual(ensure_hash_prefix("1234567"), "1234567") # Wrong length
self.assertEqual(ensure_hash_prefix("xyz"), "xyz") # Invalid hex chars self.assertEqual(ensure_hash_prefix("xyz"), "xyz") # Invalid hex chars
self.assertEqual(ensure_hash_prefix("12345g"), "12345g") # Invalid hex chars self.assertEqual(ensure_hash_prefix("12345g"), "12345g") # Invalid hex chars
def test_tool_output_color_handling(self): def test_tool_output_color_handling(self):
"""Test that tool_output correctly handles hex colors without # prefix""" """Test that tool_output correctly handles hex colors without # prefix"""
from unittest.mock import patch from unittest.mock import patch
from rich.text import Text from rich.text import Text
# Create IO with hex color without # for tool_output_color # Create IO with hex color without # for tool_output_color
io = InputOutput(tool_output_color="FFA500", pretty=True) io = InputOutput(tool_output_color="FFA500", pretty=True)
# Patch console.print to avoid actual printing # Patch console.print to avoid actual printing
with patch.object(io.console, "print") as mock_print: with patch.object(io.console, "print") as mock_print:
# This would raise ColorParseError without the fix # This would raise ColorParseError without the fix
io.tool_output("Test message") io.tool_output("Test message")
# Verify the call was made without error # Verify the call was made without error
mock_print.assert_called_once() mock_print.assert_called_once()
# Verify the style was correctly created with # prefix # Verify the style was correctly created with # prefix
# The first argument is the message, second would be the style # The first argument is the message, second would be the style
kwargs = mock_print.call_args.kwargs kwargs = mock_print.call_args.kwargs
self.assertIn("style", kwargs) self.assertIn("style", kwargs)
# Test with other hex color # Test with other hex color
io = InputOutput(tool_output_color="00FF00", pretty=True) io = InputOutput(tool_output_color="00FF00", pretty=True)
with patch.object(io.console, "print") as mock_print: with patch.object(io.console, "print") as mock_print:
io.tool_output("Test message") io.tool_output("Test message")