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

Delta Between Two Patch Sets: Lib/test/test_devpoll.py

Issue 18794: select.devpoll objects have no close() method
Left Patch Set: Created 6 years, 2 months ago
Right 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:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 # Test case for the select.devpoll() function 1 # Test case for the select.devpoll() function
2 2
3 # Initial tests are copied as is from "test_poll.py" 3 # Initial tests are copied as is from "test_poll.py"
4 4
5 import os, select, random, unittest, sys 5 import os, select, random, unittest, sys
6 from test.support import TESTFN, run_unittest 6 from test.support import TESTFN, run_unittest
7 7
8 try: 8 try:
9 select.devpoll 9 select.devpoll
10 except AttributeError: 10 except AttributeError:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 self.assertRaises(OverflowError, pollster.poll, -1 << 31) 80 self.assertRaises(OverflowError, pollster.poll, -1 << 31)
81 self.assertRaises(OverflowError, pollster.poll, -1 << 64) 81 self.assertRaises(OverflowError, pollster.poll, -1 << 64)
82 82
83 pollster.poll(0) 83 pollster.poll(0)
84 pollster.poll(1) 84 pollster.poll(1)
85 pollster.poll(1 << 30) 85 pollster.poll(1 << 30)
86 self.assertRaises(OverflowError, pollster.poll, 1 << 31) 86 self.assertRaises(OverflowError, pollster.poll, 1 << 31)
87 self.assertRaises(OverflowError, pollster.poll, 1 << 63) 87 self.assertRaises(OverflowError, pollster.poll, 1 << 63)
88 self.assertRaises(OverflowError, pollster.poll, 1 << 64) 88 self.assertRaises(OverflowError, pollster.poll, 1 << 64)
89 89
90 def test_close(self):
91 open_file = open(__file__, "rb")
92 self.addCleanup(open_file.close)
93 fd = open_file.fileno()
94 obj = select.devpoll()
95
96 # test fileno() method and closed attribute
97 fd = obj.fileno()
Charles-François Natali 2013/08/21 20:42:15 You're redefining 'fd' defined above: this shouldn
98 self.assertIsInstance(fd, int)
99 self.assertFalse(obj.closed)
100
101 # test close()
102 obj.close()
103 self.assertTrue(obj.closed)
104 self.assertRaises(ValueError, obj.fileno)
105
106 # close() can be called more than once
107 obj.close()
108
109 # operations must fail with ValueError("I/O operation on closed ...")
110 self.assertRaises(ValueError, obj.modify, fd)
111 self.assertRaises(ValueError, obj.poll, 1.0)
112 self.assertRaises(ValueError, obj.register, fd, fd, select.POLLIN)
Charles-François Natali 2013/08/21 20:42:15 devpoll.register() has only two arguments, no?
113 self.assertRaises(ValueError, obj.unregister, fd)
114
115
90 def test_main(): 116 def test_main():
91 run_unittest(DevPollTests) 117 run_unittest(DevPollTests)
92 118
93 if __name__ == '__main__': 119 if __name__ == '__main__':
94 test_main() 120 test_main()
LEFTRIGHT

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