The driver and pppoe_driver fixtures (and test_open_sets_fc_on_success) left the driver open. When it was garbage-collected, NAPALM's NetworkDriver.__del__ called is_alive(), which resolved fritz.box and connected to port 49443, once per test. __del__ swallows the error, so it only showed as slow or flaky runs (a full run took ~5.7 s, now ~0.6 s).
The fixtures close the driver after the test (fc = None, so is_alive() returns without touching the network).
tests/conftest.py adds a session-wide guard: socket.create_connection and socket.socket.connect refuse, every attempt is recorded, and the session fails at the end if any test (including a __del__) tried to connect. Tests that patch create_connection themselves are unaffected.
No driver code changes, so no CHANGELOG entry (nothing changes for users of the driver).
Tests
Fixtures only. Red first: with only the guard in place, the session failed with 70+ recorded create_connection('fritz.box', 49443) attempts; with the fixtures closing the driver it passes. pytest (74 passed), ruff format/check, mypy, napalm-standard check and ratchet are green, coverage 81.4 % (floor 81).
## What
The unit tests no longer open a socket.
The `driver` and `pppoe_driver` fixtures (and `test_open_sets_fc_on_success`) left the driver open. When it was garbage-collected, NAPALM's `NetworkDriver.__del__` called `is_alive()`, which resolved `fritz.box` and connected to port 49443, once per test. `__del__` swallows the error, so it only showed as slow or flaky runs (a full run took ~5.7 s, now ~0.6 s).
- The fixtures close the driver after the test (`fc = None`, so `is_alive()` returns without touching the network).
- `tests/conftest.py` adds a session-wide guard: `socket.create_connection` and `socket.socket.connect` refuse, every attempt is recorded, and the session fails at the end if any test (including a `__del__`) tried to connect. Tests that patch `create_connection` themselves are unaffected.
No driver code changes, so no CHANGELOG entry (nothing changes for users of the driver).
## Tests
Fixtures only. Red first: with only the guard in place, the session failed with 70+ recorded `create_connection('fritz.box', 49443)` attempts; with the fixtures closing the driver it passes. pytest (74 passed), ruff format/check, mypy, `napalm-standard check` and `ratchet` are green, coverage 81.4 % (floor 81).
Closes #11
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
The unit tests no longer open a socket.
The
driverandpppoe_driverfixtures (andtest_open_sets_fc_on_success) left the driver open. When it was garbage-collected, NAPALM'sNetworkDriver.__del__calledis_alive(), which resolvedfritz.boxand connected to port 49443, once per test.__del__swallows the error, so it only showed as slow or flaky runs (a full run took ~5.7 s, now ~0.6 s).fc = None, sois_alive()returns without touching the network).tests/conftest.pyadds a session-wide guard:socket.create_connectionandsocket.socket.connectrefuse, every attempt is recorded, and the session fails at the end if any test (including a__del__) tried to connect. Tests that patchcreate_connectionthemselves are unaffected.No driver code changes, so no CHANGELOG entry (nothing changes for users of the driver).
Tests
Fixtures only. Red first: with only the guard in place, the session failed with 70+ recorded
create_connection('fritz.box', 49443)attempts; with the fixtures closing the driver it passes. pytest (74 passed), ruff format/check, mypy,napalm-standard checkandratchetare green, coverage 81.4 % (floor 81).Closes #11