diff --git a/docs/history.rst b/docs/history.rst index bb9c268..e38664e 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -1,5 +1,8 @@ History ======= +4.0.5 + * enhancement: ``telnetlib3-client`` client shell now drains stdout. + 4.0.4 * bugfix: servers using ``robot_check=True`` with ``encoding=False`` raised ``TypeError: buf expected bytes, got ``. ``telnetlib3-server`` now also accepts ``--encoding=False`` diff --git a/pyproject.toml b/pyproject.toml index 8efca6d..9d4f131 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "telnetlib3" -version = "4.0.4" # Keep in sync with telnetlib3/accessories.py::get_version ! +version = "4.0.5" # Keep in sync with telnetlib3/accessories.py::get_version ! description = " Python Telnet server and client CLI and Protocol library" readme = "README.rst" license = "ISC" diff --git a/telnetlib3/accessories.py b/telnetlib3/accessories.py index 6233f0c..27de148 100644 --- a/telnetlib3/accessories.py +++ b/telnetlib3/accessories.py @@ -42,7 +42,7 @@ def get_version() -> str: """Return the current version of telnetlib3.""" - return "4.0.4" # keep in sync with pyproject.toml ! + return "4.0.5" # keep in sync with pyproject.toml ! def encoding_from_lang(lang: str) -> Optional[str]: diff --git a/telnetlib3/client_shell.py b/telnetlib3/client_shell.py index 353aad3..6fd8025 100644 --- a/telnetlib3/client_shell.py +++ b/telnetlib3/client_shell.py @@ -579,6 +579,8 @@ async def _raw_event_loop( if raw_mode is None and want_repl(): state.reactivate_repl = True stdout.write(out.encode()) + if hasattr(stdout, 'drain'): + await stdout.drain() _ts_file = telnet_writer.ctx.typescript_file if _ts_file is not None: _ts_file.write(out) diff --git a/telnetlib3/tests/test_client_shell.py b/telnetlib3/tests/test_client_shell.py index 968bd64..9124df9 100644 --- a/telnetlib3/tests/test_client_shell.py +++ b/telnetlib3/tests/test_client_shell.py @@ -760,8 +760,7 @@ def at_eof(self) -> bool: term = _make_term(writer) term.check_auto_mode = lambda switched_to_raw, last_will_echo: None - stdout = mock.Mock() - stdout.write = mock.Mock() + stdout = mock.Mock(spec=["write"]) close_calls: list[str] = [] @@ -823,6 +822,7 @@ def at_eof(self) -> bool: stdout = mock.Mock() stdout.write = mock.Mock() + stdout.drain = mock.AsyncMock() state = _RawLoopState( switched_to_raw=True, last_will_echo=False, local_echo=False, linesep="\r\n" @@ -839,6 +839,7 @@ def at_eof(self) -> bool: want_repl=lambda: False, ) assert "hello world" in ts_buf.getvalue() + stdout.drain.assert_called_once() @pytest.mark.asyncio