bpo-32568: make select.epoll() and its docs consistent (GH-7840) (GH-… · python/cpython@fd1c092
@@ -74,11 +74,11 @@ def test_create(self):
7474ep.close()
7575self.assertTrue(ep.closed)
7676self.assertRaises(ValueError, ep.fileno)
77+7778if hasattr(select, "EPOLL_CLOEXEC"):
78-select.epoll(select.EPOLL_CLOEXEC).close()
79+select.epoll(-1, select.EPOLL_CLOEXEC).close()
7980select.epoll(flags=select.EPOLL_CLOEXEC).close()
8081select.epoll(flags=0).close()
81-self.assertRaises(OSError, select.epoll, flags=12356)
82828383def test_badcreate(self):
8484self.assertRaises(TypeError, select.epoll, 1, 2, 3)
@@ -88,6 +88,13 @@ def test_badcreate(self):
8888self.assertRaises(TypeError, select.epoll, ['foo'])
8989self.assertRaises(TypeError, select.epoll, {})
909091+self.assertRaises(ValueError, select.epoll, 0)
92+self.assertRaises(ValueError, select.epoll, -2)
93+self.assertRaises(ValueError, select.epoll, sizehint=-2)
94+95+if hasattr(select, "EPOLL_CLOEXEC"):
96+self.assertRaises(OSError, select.epoll, flags=12356)
97+9198def test_context_manager(self):
9299with select.epoll(16) as ep:
93100self.assertGreater(ep.fileno(), 0)
@@ -117,19 +124,19 @@ def test_add(self):
117124try:
118125# TypeError: argument must be an int, or have a fileno() method.
119126self.assertRaises(TypeError, ep.register, object(),
120-select.EPOLLIN | select.EPOLLOUT)
127+ select.EPOLLIN | select.EPOLLOUT)
121128self.assertRaises(TypeError, ep.register, None,
122-select.EPOLLIN | select.EPOLLOUT)
129+ select.EPOLLIN | select.EPOLLOUT)
123130# ValueError: file descriptor cannot be a negative integer (-1)
124131self.assertRaises(ValueError, ep.register, -1,
125-select.EPOLLIN | select.EPOLLOUT)
132+ select.EPOLLIN | select.EPOLLOUT)
126133# OSError: [Errno 9] Bad file descriptor
127134self.assertRaises(OSError, ep.register, 10000,
128-select.EPOLLIN | select.EPOLLOUT)
135+ select.EPOLLIN | select.EPOLLOUT)
129136# registering twice also raises an exception
130137ep.register(server, select.EPOLLIN | select.EPOLLOUT)
131138self.assertRaises(OSError, ep.register, server,
132-select.EPOLLIN | select.EPOLLOUT)
139+ select.EPOLLIN | select.EPOLLOUT)
133140finally:
134141ep.close()
135142@@ -160,9 +167,9 @@ def test_control_and_wait(self):
160167161168ep = select.epoll(16)
162169ep.register(server.fileno(),
163-select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
170+ select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
164171ep.register(client.fileno(),
165-select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
172+ select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
166173167174now = time.monotonic()
168175events = ep.poll(1, 4)