Skip to content

Commit 10cf005

Browse files
committed
rephrase and fix typos
1 parent 317b09a commit 10cf005

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

newsfragments/760.feature.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
We added a new ``is_readable`` method to the ``trio.socket.SocketType``
2-
object that allows you to check whether a socket is ready to be read
3-
or not.
1+
Trio sockets have a new method `~trio.socket.SocketType.is_readable` that allows
2+
you to check whether a socket is readable. This is useful for HTTP/1.1 clients.

trio/tests/test_socket.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -404,21 +404,15 @@ async def test_SocketType_simple_server(address, socket_type):
404404
assert await client.recv(1) == b"x"
405405

406406

407-
async def test_SocketTupe_is_readable():
408-
listener = tsocket.socket(tsocket.AF_INET)
409-
client = tsocket.socket(tsocket.AF_INET)
410-
with listener, client:
411-
await listener.bind(('127.0.0.1', 0))
412-
listener.listen(20)
413-
addr = listener.getsockname()[:2]
414-
async with _core.open_nursery() as nursery:
415-
nursery.start_soon(client.connect, addr)
416-
server, client_addr = await listener.accept()
417-
with server:
418-
assert not client.is_readable()
419-
await server.send(b"x")
420-
assert client.is_readable()
421-
assert await client.recv(1) == b"x"
407+
async def test_SocketType_is_readable():
408+
a, b = tsocket.socketpair()
409+
with a, b:
410+
assert not a.is_readable()
411+
await b.send(b"x")
412+
await _core.wait_readable(a)
413+
assert a.is_readable()
414+
assert await a.recv(1) == b"x"
415+
assert not a.is_readable()
422416

423417

424418
# On some macOS systems, getaddrinfo likes to return V4-mapped addresses even

0 commit comments

Comments
 (0)