From b4b370e6239419b8156ab373fd8e29970c0a9ffd Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 9 Feb 2026 17:10:17 -0500 Subject: [PATCH 1/2] Fix test_wantWriteError failure on macOS Use Unix domain sockets instead of TCP loopback. On macOS, TCP loopback aggressively auto-tunes buffer sizes and drains the send buffer into the peer's receive buffer nearly instantly, so the send buffer won't stay full long enough for do_handshake() to observe it, resulting in WantReadError instead of the expected WantWriteError. Co-Authored-By: Claude Opus 4.6 --- tests/test_ssl.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_ssl.py b/tests/test_ssl.py index b4506afc..247cb229 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -37,6 +37,7 @@ SOL_SOCKET, gaierror, socket, + socketpair, ) from sys import getfilesystemencoding, platform from weakref import ref @@ -3070,7 +3071,14 @@ def test_wantWriteError(self) -> None: `OpenSSL.SSL.WantWriteError` if writing to the connection's BIO fail indicating a should-write state. """ - client_socket, _ = socket_pair() + # Use Unix domain sockets rather than TCP loopback. On macOS, + # TCP loopback aggressively auto-tunes buffer sizes and drains + # the send buffer into the peer's receive buffer nearly + # instantly, so the send buffer won't stay full long enough + # for do_handshake() to observe it. + client_socket, peer = socketpair() + client_socket.setblocking(False) + peer.setblocking(False) # Fill up the client's send buffer so Connection won't be able to write # anything. Start by sending larger chunks (Windows Socket I/O is slow) # and continue by writing a single byte at a time so we can be sure we From 1a506c8f2799029e6444c011baf3a42077517dcc Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 9 Feb 2026 17:28:39 -0500 Subject: [PATCH 2/2] Fix RUF061: use context-manager form of pytest.deprecated_call() Co-Authored-By: Claude Opus 4.6 --- tests/test_ssl.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_ssl.py b/tests/test_ssl.py index 247cb229..0dd25328 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -671,7 +671,8 @@ def test_load_client_ca_unicode( """ Passing the path as unicode raises a warning but works. """ - pytest.deprecated_call(context.load_client_ca, ca_file.decode("ascii")) + with pytest.deprecated_call(): + context.load_client_ca(ca_file.decode("ascii")) # type: ignore[arg-type] def test_set_session_id(self, context: Context) -> None: """ @@ -706,7 +707,8 @@ def test_set_session_id_unicode(self, context: Context) -> None: `Context.set_session_id` raises a warning if a unicode string is passed. """ - pytest.deprecated_call(context.set_session_id, "abc") + with pytest.deprecated_call(): + context.set_session_id("abc") # type: ignore[arg-type] def test_method(self) -> None: """