fix(tests): close fixture drivers so no test opens a socket
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m14s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / lowest (pull_request) Successful in 28s
driver / build (pull_request) Successful in 38s
driver / security (pull_request) Successful in 1m22s
CI / driver (pull_request) Successful in 2m57s
driver / publish (pull_request) Skipped

The driver fixtures and test_open_sets_fc_on_success left the driver
open. When it was collected, NAPALM's NetworkDriver.__del__ called
is_alive(), which resolved fritz.box and connected to port 49443 once
per test; the error was swallowed, so it only showed as slow or flaky
runs.

The fixtures now close the driver after the test. A session-wide guard
in conftest refuses every connection and fails the run if any test,
including a __del__, tried one.

Closes #11
This commit is contained in:
Christian Manivong committed 2026-11-02 08:35:26 +01:00
1 parent 75d4257793
commit 244e7f4992
2 files changed
+41

No files matched your search

+5
View File
@@ -268,6 +268,8 @@ def driver():
drv = FritzBoxDriver(hostname="fritz.box", username="user", password="pass")
drv.fc = mock_fc
yield drv
# An open driver makes NAPALM's __del__ probe fritz.box over the network (#11).
drv.close()
@pytest.fixture
@@ -288,6 +290,8 @@ def pppoe_driver():
drv = FritzBoxDriver(hostname="fritz.box", username="user", password="pass")
drv.fc = mock_fc
yield drv
# An open driver makes NAPALM's __del__ probe fritz.box over the network (#11).
drv.close()
# ---------------------------------------------------------------------------
@@ -309,6 +313,7 @@ class TestOpenClose:
with patch("napalm_fritzbox.fritzbox.FritzConnection", return_value=mock_fc):
drv.open()
assert drv.fc is mock_fc
drv.close()
def test_close_clears_fc(self, driver):
driver.close()