Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(81849)

Side by Side Diff: Lib/test/test_epoll.py

Issue 18794: select.devpoll objects have no close() method
Patch Set: Created 6 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2001-2006 Twisted Matrix Laboratories. 1 # Copyright (c) 2001-2006 Twisted Matrix Laboratories.
2 # 2 #
3 # Permission is hereby granted, free of charge, to any person obtaining 3 # Permission is hereby granted, free of charge, to any person obtaining
4 # a copy of this software and associated documentation files (the 4 # a copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including 5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, 6 # without limitation the rights to use, copy, modify, merge, publish,
7 # distribute, sublicense, and/or sell copies of the Software, and to 7 # distribute, sublicense, and/or sell copies of the Software, and to
8 # permit persons to whom the Software is furnished to do so, subject to 8 # permit persons to whom the Software is furnished to do so, subject to
9 # the following conditions: 9 # the following conditions:
10 # 10 #
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 ep = select.epoll(16) 217 ep = select.epoll(16)
218 ep.register(server) 218 ep.register(server)
219 219
220 now = time.time() 220 now = time.time()
221 events = ep.poll(1, 4) 221 events = ep.poll(1, 4)
222 then = time.time() 222 then = time.time()
223 self.assertFalse(then - now > 0.01) 223 self.assertFalse(then - now > 0.01)
224 224
225 server.close() 225 server.close()
226 ep.unregister(fd) 226 ep.unregister(fd)
227
228 def test_close(self):
229 open_file = open(__file__, "rb")
230 self.addCleanup(open_file.close)
231 fd = open_file.fileno()
232 obj = select.epoll()
233
234 # test fileno() method and closed attribute
235 fd = obj.fileno()
Charles-Fran├žois Natali 2013/08/21 20:42:15 You're redefining 'fd' defined above: this shouldn
236 self.assertIsInstance(fd, int)
237 self.assertFalse(obj.closed)
238
239 # test close()
240 obj.close()
241 self.assertTrue(obj.closed)
242 self.assertRaises(ValueError, obj.fileno)
243
244 # close() can be called more than once
245 obj.close()
246
247 # operations must fail with ValueError("I/O operation on closed ...")
248 self.assertRaises(ValueError, obj.modify, fd, select.EPOLLIN)
249 self.assertRaises(ValueError, obj.poll, 1.0)
250 self.assertRaises(ValueError, obj.register, fd, select.EPOLLIN)
251 self.assertRaises(ValueError, obj.unregister, fd)
252
227 253
228 def test_main(): 254 def test_main():
229 support.run_unittest(TestEPoll) 255 support.run_unittest(TestEPoll)
230 256
231 if __name__ == "__main__": 257 if __name__ == "__main__":
232 test_main() 258 test_main()
OLDNEW

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+