summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_devpoll.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-08-21 22:19:50 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-08-21 22:19:50 (GMT)
commit13423c3726ac4aa42125ac49e6c5038a015fe3eb (patch)
tree6658b82985abb3f4c2a201cb2a6320dcc5391a66 /Lib/test/test_devpoll.py
parent43f80e6c1f49c3590843d81a1b5ebbe1a2e1c62a (diff)
downloadcpython-13423c3726ac4aa42125ac49e6c5038a015fe3eb.zip
cpython-13423c3726ac4aa42125ac49e6c5038a015fe3eb.tar.gz
cpython-13423c3726ac4aa42125ac49e6c5038a015fe3eb.tar.bz2
Close #18794: Add a fileno() method and a closed attribute to select.devpoll
objects. Add also tests on fileno() method and closed attribute of select.epoll and select.kqueue.
Diffstat (limited to 'Lib/test/test_devpoll.py')
-rw-r--r--Lib/test/test_devpoll.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_devpoll.py b/Lib/test/test_devpoll.py
index ec350cd..167e0ee 100644
--- a/Lib/test/test_devpoll.py
+++ b/Lib/test/test_devpoll.py
@@ -87,6 +87,31 @@ class DevPollTests(unittest.TestCase):
self.assertRaises(OverflowError, pollster.poll, 1 << 63)
self.assertRaises(OverflowError, pollster.poll, 1 << 64)
+ def test_close(self):
+ open_file = open(__file__, "rb")
+ self.addCleanup(open_file.close)
+ fd = open_file.fileno()
+ devpoll = select.devpoll()
+
+ # test fileno() method and closed attribute
+ self.assertIsInstance(devpoll.fileno(), int)
+ self.assertFalse(devpoll.closed)
+
+ # test close()
+ devpoll.close()
+ self.assertTrue(devpoll.closed)
+ self.assertRaises(ValueError, devpoll.fileno)
+
+ # close() can be called more than once
+ devpoll.close()
+
+ # operations must fail with ValueError("I/O operation on closed ...")
+ self.assertRaises(ValueError, devpoll.modify, fd, select.POLLIN)
+ self.assertRaises(ValueError, devpoll.poll)
+ self.assertRaises(ValueError, devpoll.register, fd, fd, select.POLLIN)
+ self.assertRaises(ValueError, devpoll.unregister, fd)
+
+
def test_main():
run_unittest(DevPollTests)