refactor: prepare the interactive shell in its own module
driver / standard (pull_request) Successful in 40s
driver / lint (pull_request) Successful in 27s
driver / test (3.10) (pull_request) Successful in 3m57s
driver / test (3.11) (pull_request) Successful in 1m7s
driver / test (3.12) (pull_request) Successful in 1m9s
driver / types (pull_request) Successful in 19m18s
driver / lowest (pull_request) Successful in 43s
driver / security (pull_request) Successful in 1m3s
driver / build (pull_request) Successful in 58s
driver / test (3.13) (pull_request) Successful in 16m1s
CI / driver (pull_request) Successful in 23m9s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 40s
driver / lint (pull_request) Successful in 27s
driver / test (3.10) (pull_request) Successful in 3m57s
driver / test (3.11) (pull_request) Successful in 1m7s
driver / test (3.12) (pull_request) Successful in 1m9s
driver / types (pull_request) Successful in 19m18s
driver / lowest (pull_request) Successful in 43s
driver / security (pull_request) Successful in 1m3s
driver / build (pull_request) Successful in 58s
driver / test (3.13) (pull_request) Successful in 16m1s
CI / driver (pull_request) Successful in 23m9s
driver / publish (pull_request) Skipped
The prompt-hook step (#41) pushed linux.py past its line count in the quality baseline. The three steps that make netmiko's fresh shell fit to read - history off, prompt hooks off, no line wrap - and the prompt pattern move to napalm_linux/_shell.py, under strict mypy. linux.py shrinks below where it was; the baseline follows.
This commit is contained in:
1 parent
4159612a33
commit
42e93f02dd
5 files changed
+66
-48
No files matched your search
@@ -11,7 +11,8 @@ characters and netOrk could not store the poll.
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from napalm_linux.linux import _HISTORY_OFF, _PROMPT_HOOKS_OFF, LinuxDriver
|
||||
from napalm_linux._shell import HISTORY_OFF, PROMPT_HOOKS_OFF
|
||||
from napalm_linux.linux import LinuxDriver
|
||||
|
||||
#: What ``cat /etc/os-release | grep PRETTY_NAME ...`` returned through netmiko on
|
||||
#: an Ubuntu 26.04.1 host (2026-10-23), the prompt line already gone.
|
||||
@@ -39,13 +40,13 @@ class TestPromptHooksOff:
|
||||
_opened(device)
|
||||
|
||||
sent = [c.args[0] for c in device.send_command.call_args_list]
|
||||
assert sent[:2] == [_HISTORY_OFF, _PROMPT_HOOKS_OFF]
|
||||
assert sent[:2] == [HISTORY_OFF, PROMPT_HOOKS_OFF]
|
||||
|
||||
def test_it_unsets_both_hooks_including_an_array_prompt_command(self):
|
||||
# The script appends to PROMPT_COMMAND as an array; assigning the empty
|
||||
# string would only clear element 0 and leave systemd's hook running.
|
||||
assert _PROMPT_HOOKS_OFF.startswith(" ")
|
||||
assert "unset PS0 PROMPT_COMMAND" in _PROMPT_HOOKS_OFF
|
||||
assert PROMPT_HOOKS_OFF.startswith(" ")
|
||||
assert "unset PS0 PROMPT_COMMAND" in PROMPT_HOOKS_OFF
|
||||
|
||||
def test_the_prompt_is_read_again_once_the_hooks_are_gone(self):
|
||||
# netmiko learned the prompt with the sequences in front of it; a prompt
|
||||
@@ -56,7 +57,7 @@ class TestPromptHooksOff:
|
||||
_opened(device)
|
||||
|
||||
calls = [(c[0], c.args[0] if c.args else None) for c in device.mock_calls]
|
||||
hooks_off = calls.index(("send_command", _PROMPT_HOOKS_OFF))
|
||||
hooks_off = calls.index(("send_command", PROMPT_HOOKS_OFF))
|
||||
assert "set_base_prompt" in [name for name, _ in calls[hooks_off + 1 :]]
|
||||
|
||||
def test_a_shell_that_refuses_it_does_not_stop_the_connection(self):
|
||||
|
||||
Reference in new issue
Block a user