Skip to content

Commit d7c5444

Browse files
committed
try adjusting context for stream closed warning
free threading seems to log differently
1 parent b11f126 commit d7c5444

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/test_zmqstream.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ async def test_shadow_socket(context):
134134

135135

136136
async def test_shadow_socket_close(context, caplog):
137-
with context.socket(zmq.PUSH) as push, context.socket(zmq.PULL) as pull:
137+
with warnings.catch_warnings(record=True) as records, context.socket(
138+
zmq.PUSH
139+
) as push, context.socket(zmq.PULL) as pull:
138140
push.linger = pull.linger = 0
139141
port = push.bind_to_random_port('tcp://127.0.0.1')
140142
pull.connect(f'tcp://127.0.0.1:{port}')
@@ -150,10 +152,10 @@ async def test_shadow_socket_close(context, caplog):
150152
stream.on_recv(print)
151153
# close the shadowed socket
152154
pull.close()
153-
# run the event loop, which should see some events on the shadow socket
154-
# but the socket has been closed!
155-
with warnings.catch_warnings(record=True) as records:
155+
# run the event loop, which should see some events on the shadow socket
156+
# but the socket has been closed!
156157
await asyncio.sleep(0.2)
158+
stream.close()
157159
warning_text = "\n".join(str(r.message) for r in records)
158160
assert "after closing socket" in warning_text
159161
assert "closed socket" in caplog.text

0 commit comments

Comments
 (0)