From abb59b3d063efc05c9136eaeafc98cfcf5b4a13e Mon Sep 17 00:00:00 2001 From: yueguobin Date: Sat, 31 Oct 2026 16:38:58 +0800 Subject: [PATCH] test(vpcs): mock read_channel in the strip-ansi test The send_command read loop polls read_channel (netmiko decorates it with a session-lock wrapper that only __init__ can satisfy), so the old read_until_pattern mock died with AttributeError on instances built via __new__. --- .../utils/custom_netmiko/tests/test_vpcs_telnet.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_vpcs_telnet.py b/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_vpcs_telnet.py index d0c66f821..0a8624953 100644 --- a/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_vpcs_telnet.py +++ b/gns3server/agent/gns3_copilot/utils/custom_netmiko/tests/test_vpcs_telnet.py @@ -429,10 +429,12 @@ IP/MASK : 192.168.1.20/24""" instance = self.VPCSTelnet.__new__(self.VPCSTelnet) - # Mock necessary attributes + # Mock necessary attributes. The read loop polls read_channel + # (netmiko's decorated method needs the session lock, which only + # __init__ creates), not read_until_pattern. instance.remote_conn = MagicMock() instance.remote_conn.write = MagicMock() - instance.read_until_pattern = MagicMock(return_value="\x1b[1mNAME\x1b[0m : PC2\nPC2>") + instance.read_channel = MagicMock(return_value="\x1b[1mNAME\x1b[0m : PC2\nPC2>") # Mock _strip_ansi_codes to verify it's called instance._strip_ansi_codes = Mock(return_value="NAME : PC2\nPC2>")