diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-12-17 11:14:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 11:14:25 (GMT) |
commit | 718bf1a7a1a39ca6f2381a299d00d8318732104a (patch) | |
tree | 081a93865fff3d16fda95bcd1ad77d10a1e7b069 /Lib | |
parent | dd262ef46d2e2fff4c413cfa5faa9e72cd36220e (diff) | |
download | cpython-718bf1a7a1a39ca6f2381a299d00d8318732104a.zip cpython-718bf1a7a1a39ca6f2381a299d00d8318732104a.tar.gz cpython-718bf1a7a1a39ca6f2381a299d00d8318732104a.tar.bz2 |
bpo-41804: Enhance test_epoll.test_control_and_wait() (GH-23795) (GH-23814)
Use shorter timeout and replace send() with sendall().
(cherry picked from commit 79782fe4f8cf73d7fdf8db02073bbadf7ff817b6)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_epoll.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py index 8ac0f31..e7d5835 100644 --- a/Lib/test/test_epoll.py +++ b/Lib/test/test_epoll.py @@ -160,44 +160,42 @@ class TestEPoll(unittest.TestCase): self.fail("epoll on closed fd didn't raise EBADF") def test_control_and_wait(self): + # create the epoll object client, server = self._connected_pair() - ep = select.epoll(16) ep.register(server.fileno(), select.EPOLLIN | select.EPOLLOUT | select.EPOLLET) ep.register(client.fileno(), select.EPOLLIN | select.EPOLLOUT | select.EPOLLET) + # EPOLLOUT now = time.monotonic() events = ep.poll(1, 4) then = time.monotonic() self.assertFalse(then - now > 0.1, then - now) - events.sort() expected = [(client.fileno(), select.EPOLLOUT), (server.fileno(), select.EPOLLOUT)] - expected.sort() - - self.assertEqual(events, expected) + self.assertEqual(sorted(events), sorted(expected)) - events = ep.poll(timeout=2.1, maxevents=4) + # no event + events = ep.poll(timeout=0.1, maxevents=4) self.assertFalse(events) - client.send(b"Hello!") - server.send(b"world!!!") + # send: EPOLLIN and EPOLLOUT + client.sendall(b"Hello!") + server.sendall(b"world!!!") now = time.monotonic() - events = ep.poll(1, 4) + events = ep.poll(1.0, 4) then = time.monotonic() self.assertFalse(then - now > 0.01) - events.sort() expected = [(client.fileno(), select.EPOLLIN | select.EPOLLOUT), (server.fileno(), select.EPOLLIN | select.EPOLLOUT)] - expected.sort() - - self.assertEqual(events, expected) + self.assertEqual(sorted(events), sorted(expected)) + # unregister, modify ep.unregister(client.fileno()) ep.modify(server.fileno(), select.EPOLLOUT) now = time.monotonic() |