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

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

Issue 18794: select.devpoll objects have no close() method
Patch Set: Created 6 years, 3 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 """ 1 """
2 Tests for kqueue wrapper. 2 Tests for kqueue wrapper.
3 """ 3 """
4 import errno 4 import errno
5 import os 5 import os
6 import select 6 import select
7 import socket 7 import socket
8 import sys 8 import sys
9 import time 9 import time
10 import unittest 10 import unittest
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | sele ct.KQ_EV_ENABLE) 177 event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | sele ct.KQ_EV_ENABLE)
178 event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | sele ct.KQ_EV_ENABLE) 178 event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | sele ct.KQ_EV_ENABLE)
179 r = kq.control([event1, event2], 1, 1) 179 r = kq.control([event1, event2], 1, 1)
180 self.assertTrue(r) 180 self.assertTrue(r)
181 self.assertFalse(r[0].flags & select.KQ_EV_ERROR) 181 self.assertFalse(r[0].flags & select.KQ_EV_ERROR)
182 self.assertEqual(b.recv(r[0].data), b'foo') 182 self.assertEqual(b.recv(r[0].data), b'foo')
183 183
184 a.close() 184 a.close()
185 b.close() 185 b.close()
186 kq.close() 186 kq.close()
187
188 def test_close(self):
189 open_file = open(__file__, "rb")
190 self.addCleanup(open_file.close)
191 fd = open_file.fileno()
192 obj = select.kqueue()
193
194 # test fileno() method and closed attribute
195 fd = obj.fileno()
196 self.assertIsInstance(fd, int)
197 self.assertFalse(obj.closed)
198
199 # test close()
200 obj.close()
201 self.assertTrue(obj.closed)
202 self.assertRaises(ValueError, obj.fileno)
203
204 # close() can be called more than once
205 obj.close()
206
187 207
188 def test_main(): 208 def test_main():
189 support.run_unittest(TestKQueue) 209 support.run_unittest(TestKQueue)
190 210
191 if __name__ == "__main__": 211 if __name__ == "__main__":
192 test_main() 212 test_main()
OLDNEW
« Lib/test/test_epoll.py ('K') | « Lib/test/test_epoll.py ('k') | Modules/selectmodule.c » ('j') | no next file with comments »

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