Fix WebCRT connect crash from invalid Netmiko session_log wrapper.

Use a BytesIO subclass for live connect echo so Netmiko accepts the log object again.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-28 21:55:20 +08:00
parent 6ed08e24de
commit 6aedd2c522
3 changed files with 43 additions and 48 deletions

View file

@ -14,6 +14,16 @@ from netx_api.ne_session_connect import (
class PromptDetectTests(unittest.TestCase):
def test_progress_bytesio_is_netmiko_compatible(self) -> None:
import io
from netx_api.ne_session_connect import _ProgressBytesIO
buf = _ProgressBytesIO(lambda _t: None)
self.assertIsInstance(buf, io.BufferedIOBase)
# Plain custom log objects are what broke every WebCRT connect (ValueError).
self.assertFalse(isinstance(object(), io.BufferedIOBase))
def test_huawei_username_and_password(self) -> None:
self.assertEqual(
_prompt_needs_auth("Please input the username:"),