Skip to content

Commit 51f6941

Browse files
committed
tests/sockets: Test that loop.sock_*() methods error on blocking socks
1 parent 39f3a02 commit 51f6941

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_sockets.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ async def run():
8282

8383
self.loop.run_until_complete(run())
8484

85+
def test_socket_blocking_error(self):
86+
self.loop.set_debug(True)
87+
sock = socket.socket()
88+
89+
with sock:
90+
with self.assertRaisesRegex(ValueError, 'must be non-blocking'):
91+
self.loop.sock_recv(sock, 0)
92+
93+
with self.assertRaisesRegex(ValueError, 'must be non-blocking'):
94+
self.loop.sock_sendall(sock, b'')
95+
96+
with self.assertRaisesRegex(ValueError, 'must be non-blocking'):
97+
self.loop.sock_accept(sock)
98+
99+
with self.assertRaisesRegex(ValueError, 'must be non-blocking'):
100+
self.loop.sock_connect(sock, (b'', 0))
101+
85102

86103
class TestUVSockets(_TestSockets, tb.UVTestCase):
87104
pass

0 commit comments

Comments
 (0)