[3.6] bpo-32568: make select.epoll() and its docs consistent (GH-7840… · python/cpython@db7ac30 (original) (raw)
`@@ -74,9 +74,11 @@ def test_create(self):
`
74
74
`ep.close()
`
75
75
`self.assertTrue(ep.closed)
`
76
76
`self.assertRaises(ValueError, ep.fileno)
`
``
77
+
77
78
`if hasattr(select, "EPOLL_CLOEXEC"):
`
78
``
`-
select.epoll(select.EPOLL_CLOEXEC).close()
`
79
``
`-
self.assertRaises(OSError, select.epoll, flags=12356)
`
``
79
`+
select.epoll(-1, select.EPOLL_CLOEXEC).close()
`
``
80
`+
select.epoll(flags=select.EPOLL_CLOEXEC).close()
`
``
81
`+
select.epoll(flags=0).close()
`
80
82
``
81
83
`def test_badcreate(self):
`
82
84
`self.assertRaises(TypeError, select.epoll, 1, 2, 3)
`
`@@ -86,6 +88,13 @@ def test_badcreate(self):
`
86
88
`self.assertRaises(TypeError, select.epoll, ['foo'])
`
87
89
`self.assertRaises(TypeError, select.epoll, {})
`
88
90
``
``
91
`+
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
+
89
98
`def test_context_manager(self):
`
90
99
`with select.epoll(16) as ep:
`
91
100
`self.assertGreater(ep.fileno(), 0)
`
`@@ -115,19 +124,19 @@ def test_add(self):
`
115
124
`try:
`
116
125
`# TypeError: argument must be an int, or have a fileno() method.
`
117
126
`self.assertRaises(TypeError, ep.register, object(),
`
118
``
`-
select.EPOLLIN | select.EPOLLOUT)
`
``
127
`+
select.EPOLLIN | select.EPOLLOUT)
`
119
128
`self.assertRaises(TypeError, ep.register, None,
`
120
``
`-
select.EPOLLIN | select.EPOLLOUT)
`
``
129
`+
select.EPOLLIN | select.EPOLLOUT)
`
121
130
`# ValueError: file descriptor cannot be a negative integer (-1)
`
122
131
`self.assertRaises(ValueError, ep.register, -1,
`
123
``
`-
select.EPOLLIN | select.EPOLLOUT)
`
``
132
`+
select.EPOLLIN | select.EPOLLOUT)
`
124
133
`# OSError: [Errno 9] Bad file descriptor
`
125
134
`self.assertRaises(OSError, ep.register, 10000,
`
126
``
`-
select.EPOLLIN | select.EPOLLOUT)
`
``
135
`+
select.EPOLLIN | select.EPOLLOUT)
`
127
136
`# registering twice also raises an exception
`
128
137
`ep.register(server, select.EPOLLIN | select.EPOLLOUT)
`
129
138
`self.assertRaises(OSError, ep.register, server,
`
130
``
`-
select.EPOLLIN | select.EPOLLOUT)
`
``
139
`+
select.EPOLLIN | select.EPOLLOUT)
`
131
140
`finally:
`
132
141
`ep.close()
`
133
142
``
`@@ -158,9 +167,9 @@ def test_control_and_wait(self):
`
158
167
``
159
168
`ep = select.epoll(16)
`
160
169
`ep.register(server.fileno(),
`
161
``
`-
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
`
``
170
`+
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
`
162
171
`ep.register(client.fileno(),
`
163
``
`-
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
`
``
172
`+
select.EPOLLIN | select.EPOLLOUT | select.EPOLLET)
`
164
173
``
165
174
`now = time.monotonic()
`
166
175
`events = ep.poll(1, 4)
`