diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d0cf84..feb7de6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ recorded here; their history is the git log. - `get_arp_table()` reports an unknown age as `-1.0` (napalm-device-types' `ARP_AGE_UNKNOWN`) instead of `0.0`, which means "confirmed just now": neither `ip neigh` nor `/proc/net/arp` has an age (NetOrk/netork#1327). +- The driver no longer removes `port` from the `optional_args` dict it is given: + the caller's dict stays as it was (#19). ## [0.7.0] - 2026-10-23 diff --git a/napalm_openwrt/openwrt.py b/napalm_openwrt/openwrt.py index f48b3ee..47e513c 100644 --- a/napalm_openwrt/openwrt.py +++ b/napalm_openwrt/openwrt.py @@ -109,8 +109,8 @@ class OpenWrtDriver( self.timeout = timeout self.device: ConnectHandler | None = None - if optional_args is None: - optional_args = {} + # A copy: the caller's dict stays as it was. + optional_args = dict(optional_args or {}) self.port = optional_args.pop("port", 22) self.netmiko_optional_args = netmiko_args(optional_args) diff --git a/tests/unit/test_driver.py b/tests/unit/test_driver.py index 20fa1f4..179f792 100644 --- a/tests/unit/test_driver.py +++ b/tests/unit/test_driver.py @@ -1940,3 +1940,13 @@ class TestGetSystemConfigBridgeStp: # Nothing to have an opinion about — distinct from "STP is off". driver._send_command = _system_send(network_out="network.lan=interface\n") assert driver.get_system_config()["bridge_stp"] is None + + +class TestOptionalArgs: + def test_the_callers_optional_args_are_left_as_they_were(self): + optional_args = {"port": 2222, "conn_timeout": 15} + + drv = OpenWrtDriver("192.168.1.1", "root", "", optional_args=optional_args) + + assert drv.port == 2222 + assert optional_args == {"port": 2222, "conn_timeout": 15}