fix(tests): keep the open() failure test off the network
driver / standard (pull_request) Failing after 20s
driver / lint (pull_request) Successful in 21s
driver / types (pull_request) Successful in 1m10s
driver / test (3.12) (pull_request) Successful in 1m44s
driver / test (3.13) (pull_request) Successful in 1m28s
driver / lowest (pull_request) Successful in 56s
driver / build (pull_request) Successful in 34s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Failing after 3m33s
driver / publish (pull_request) Skipped

test_open_raises_connection_exception_on_error called open() on
"unreachable.invalid" unpatched, so the unit test resolved the name
through the host's resolver and depended on it failing fast. Patch
requests.Session.get to refuse the connection and check that open()
raises ConnectionException and leaves no session behind.

Closes #41
This commit is contained in:
Christian Manivong committed 2026-11-02 08:37:58 +01:00
1 parent 0f730a4b9d
commit 96a4a139d0
2 files changed
+11 -2

No files matched your search

+3
View File
@@ -48,6 +48,9 @@ All notable changes to this driver. The format follows
the reservation anyway: a retry then failed with "Kea rejected DHCP reservation"
instead of the real error, or left two reservations for one address, which Kea
refuses to load (#40).
- The unit tests no longer reach the network: the test of a failed `open()` looked
up a real host name and waited for the resolver, so it hung or behaved differently
on a build host with a slow resolver or one that answers every name (#41).
## [0.5.0] - 2026-10-23
+8 -2
View File
@@ -132,8 +132,14 @@ class TestOpenClose:
password="s",
optional_args={"verify": False},
)
with pytest.raises(ConnectionException):
drv.open()
refused = requests.exceptions.ConnectionError("Connection refused")
with patch.object(requests.Session, "get", side_effect=refused) as get:
with pytest.raises(ConnectionException, match="Connection refused"):
drv.open()
get.assert_called_once()
assert get.call_args.args[0] == "https://unreachable.invalid/api/core/system/status"
assert drv.session is None
def test_close_clears_session(self, driver):
driver.close()