8000 bpo-41804: Enhance test_epoll.test_control_and_wait() (GH-23795) · python/cpython@79782fe · GitHub
[go: up one dir, main page]

Skip to content

Commit 79782fe

Browse files
authored
bpo-41804: Enhance test_epoll.test_control_and_wait() (GH-23795)
Use shorter timeout and replace send() with sendall().
1 parent b32d8b4 commit 79782fe

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Lib/test/test_epoll.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,44 +160,42 @@ def test_fromfd(self):
160160
self.fail("epoll on closed fd didn't raise EBADF")
161161

162162
def test_control_and_wait(self):
163+
# create the epoll object
163164
client, server = self._connected_pair()
164-
165165
ep = select.epoll(16)
166166
ep.register(server.fileno(),
167167
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
168168
ep.register(client.fileno(),
169169
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
170170

171+
# EPOLLOUT
171172
now = time.monotonic()
172173
events = ep.poll(1, 4)
173174
then = time.monotonic()
174175
self.assertFalse(then - now > 0.1, then - now)
175176

176-
events.sort()
177177
expected = [(client.fileno(), select.EPOLLOUT),
178178
(server.fileno(), select.EPOLLOUT)]
179-
expected.sort()
180-
181-
self.assertEqual(events, expected)
179+
self.assertEqual(sorted(events), sorted(expected))
182180

183-
events = ep.poll(timeout=2.1, maxevents=4)
181+
# no event
182+
events = ep.poll(timeout=0.1, maxevents=4)
184183
self.assertFalse(events)
185184

186-
client.send(b"Hello!")
187-
server.send(b"world!!!")
185+
# send: EPOLLIN and EPOLLOUT
186+
client.sendall(b"Hello!")
187+
server.sendall(b"world!!!")
188188

189189
now = time.monotonic()
190-
events = ep.poll(1, 4)
190+
events = ep.poll(1.0, 4)
191191
then = time.monotonic()
192192
self.assertFalse(then - now > 0.01)
193193

194-
events.sort()
195194
expected = [(client.fileno(), select.EPOLLIN | select.EPOLLOUT),
196195
(server.fileno(), select.EPOLLIN | select.EPOLLOUT)]
197-
expected.sort()
198-
199-
self.assertEqual(events, expected)
196+
self.assertEqual(sorted(events), sorted(expected))
200197

198+
# unregister, modify
201199
ep.unregister(client.fileno())
202200
ep.modify(server.fileno(), select.EPOLLOUT)
203201
now = time.monotonic()

0 commit comments

Comments
 (0)
0