Skip to content

The agent that grows with you

test(logging): trim #92281 line-buffer tests to two invariants

kshitijk4poor4f323eda8900
diff --git a/tests/test_hermes_logging.py b/tests/test_hermes_logging.py
index bb4881ac5cb..3842d4fd8b8 100644
--- a/tests/test_hermes_logging.py
+++ b/tests/test_hermes_logging.py
@@ -774,7 +774,6 @@ class TestLineBufferPipedStdout:
agent loop incrementally (#92281); a TTY stdout is left alone."""
def _fake_stdout(self, isatty: bool):
- from types import SimpleNamespace
from unittest.mock import MagicMock
stream = MagicMock()
@@ -782,28 +781,18 @@ class TestLineBufferPipedStdout:
stream.reconfigure = MagicMock()
return stream
- def test_piped_stdout_reconfigured_line_buffered(self, monkeypatch):
- stream = self._fake_stdout(isatty=False)
- monkeypatch.setattr(sys, "stdout", stream)
- hermes_logging._line_buffer_piped_stdout()
- stream.reconfigure.assert_called_once_with(line_buffering=True)
+ def test_tty_none_or_reconfigure_less_stdout_left_alone(self, monkeypatch):
+ from types import SimpleNamespace
- def test_tty_stdout_untouched(self, monkeypatch):
- stream = self._fake_stdout(isatty=True)
- monkeypatch.setattr(sys, "stdout", stream)
+ tty = self._fake_stdout(isatty=True)
+ monkeypatch.setattr(sys, "stdout", tty)
hermes_logging._line_buffer_piped_stdout()
- stream.reconfigure.assert_not_called()
+ tty.reconfigure.assert_not_called()
- def test_none_or_reconfigure_less_stdout_is_noop(self, monkeypatch):
monkeypatch.setattr(sys, "stdout", None)
hermes_logging._line_buffer_piped_stdout() # must not raise
-
- from types import SimpleNamespace
-
# A stream without reconfigure() (e.g. a print-redirect shim).
- monkeypatch.setattr(
- sys, "stdout", SimpleNamespace(isatty=lambda: False)
- )
+ monkeypatch.setattr(sys, "stdout", SimpleNamespace(isatty=lambda: False))
hermes_logging._line_buffer_piped_stdout()
def test_setup_logging_applies_it_to_piped_stdout(self, tmp_path, monkeypatch):