Skip to content

Commit

Permalink
🤖 Auto-fix Python linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Jan 15, 2025
1 parent ac36c64 commit 90611a0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/unit/test_log_streamer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from unittest.mock import Mock, patch
from unittest.mock import Mock

from openhands.runtime.utils.log_streamer import LogStreamer

Expand All @@ -11,12 +11,14 @@ def setUp(self):

def test_init_failure_handling(self):
"""Test that LogStreamer handles initialization failures gracefully."""
self.mock_container.logs.side_effect = Exception("Test error")
self.mock_container.logs.side_effect = Exception('Test error')

streamer = LogStreamer(self.mock_container, self.mock_log_fn)
self.assertIsNone(streamer.stdout_thread)
self.assertIsNone(streamer.log_generator)
self.mock_log_fn.assert_called_with('error', 'Failed to initialize log streaming: Test error')
self.mock_log_fn.assert_called_with(
'error', 'Failed to initialize log streaming: Test error'
)

def test_stream_logs_without_generator(self):
"""Test that _stream_logs handles missing log generator gracefully."""
Expand Down Expand Up @@ -46,8 +48,10 @@ def test_normal_operation(self):
# Verify logs were processed
expected_calls = [
('debug', '[inside container] test log 1'),
('debug', '[inside container] test log 2')
('debug', '[inside container] test log 2'),
]
actual_calls = [
(args[0], args[1]) for args, _ in self.mock_log_fn.call_args_list
]
actual_calls = [(args[0], args[1]) for args, _ in self.mock_log_fn.call_args_list]
for expected in expected_calls:
self.assertIn(expected, actual_calls)

0 comments on commit 90611a0

Please sign in to comment.