Skip to content

Commit fdebe56

Browse files
committed
PYTHON-5781 Fix TestReceiveData failures on PyPy
On PyPy, receive_data takes the wait_for_read() path before calling recv_into(). wait_for_read() checks sock.fileno() == -1 as an early exit; without a real return value, sock.pending() > 0 raises TypeError on PyPy (MagicMock comparison against int is not supported). Set fileno() = -1 on the mock so wait_for_read returns immediately.
1 parent de16f7a commit fdebe56

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

test/test_network_layer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ def _make_compression_header(op_code, uncompressed_size, compressor_id):
4545
def _make_conn():
4646
conn = MagicMock()
4747
conn.conn.gettimeout.return_value = None
48+
# PyPy calls wait_for_read() before recv_into(), which checks fileno() == -1
49+
# as an early-exit. Without this, sock.fileno() returns a MagicMock and the
50+
# subsequent sock.pending() > 0 comparison raises TypeError on PyPy.
51+
conn.conn.sock.fileno.return_value = -1
4852
return conn
4953

5054

0 commit comments

Comments
 (0)