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

Side by Side Diff: Lib/test/test_select.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
« no previous file with comments | « Doc/library/select.rst ('k') | Modules/selectmodule.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import errno 1 import errno
2 import os 2 import os
3 import select 3 import select
4 import sys 4 import sys
5 import unittest 5 import unittest
6 from test import support 6 from test import support
7 7
8 @unittest.skipIf((sys.platform[:3]=='win'), 8 @unittest.skipIf((sys.platform[:3]=='win'),
9 "can't easily test on this system") 9 "can't easily test on this system")
10 class SelectTestCase(unittest.TestCase): 10 class SelectTestCase(unittest.TestCase):
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 # Issue 16230: Crash on select resized list 68 # Issue 16230: Crash on select resized list
69 def test_select_mutated(self): 69 def test_select_mutated(self):
70 a = [] 70 a = []
71 class F: 71 class F:
72 def fileno(self): 72 def fileno(self):
73 del a[-1] 73 del a[-1]
74 return sys.__stdout__.fileno() 74 return sys.__stdout__.fileno()
75 a[:] = [F()] * 10 75 a[:] = [F()] * 10
76 self.assertEqual(select.select([], a, []), ([], a[:5], [])) 76 self.assertEqual(select.select([], a, []), ([], a[:5], []))
77 77
78
79 class CloseTest(unittest.TestCase):
Charles-Fran├žois Natali 2013/08/21 18:57:49 I think those tests should be moved to test_devpol
80 def setUp(self):
81 self.open_file = open(__file__, "rb")
82 self.addCleanup(self.open_file.close)
83
84 def check_fileno_close(self, obj):
85 fd = obj.fileno()
86 self.assertIsInstance(fd, int)
87 self.assertFalse(obj.closed)
88
89 obj.close()
90 self.assertTrue(obj.closed)
91 self.assertRaises(ValueError, obj.fileno)
92
93 @unittest.skipUnless(hasattr(select, "devpoll"), "need select.devpoll")
94 def test_devpoll(self):
95 fd = self.open_file.fileno()
96
97 obj = select.devpoll()
98 self.check_fileno_close(obj)
99 self.assertRaises(ValueError, obj.modify, fd)
100 self.assertRaises(ValueError, obj.poll, 1.0)
101 self.assertRaises(ValueError, obj.register, fd, fd, select.POLLIN)
102 self.assertRaises(ValueError, obj.unregister, fd)
103
104 @unittest.skipUnless(hasattr(select, "epoll"), "need select.epoll")
105 def test_epoll(self):
106 fd = self.open_file.fileno()
107 obj = select.epoll()
108
109 self.check_fileno_close(obj)
110
111 self.assertRaises(ValueError, obj.modify, fd, select.EPOLLIN)
112 self.assertRaises(ValueError, obj.poll, 1.0)
113 self.assertRaises(ValueError, obj.register, fd, select.EPOLLIN)
114 self.assertRaises(ValueError, obj.unregister, fd)
115
116 @unittest.skipUnless(hasattr(select, "kqueue"), "need select.kqueue")
117 def test_kqueue(self):
118 obj = select.kqueue()
119 self.check_fileno_close(obj)
120
121
122
78 def test_main(): 123 def test_main():
79 support.run_unittest(SelectTestCase) 124 support.run_unittest(
125 SelectTestCase,
126 CloseTest)
80 support.reap_children() 127 support.reap_children()
81 128
82 if __name__ == "__main__": 129 if __name__ == "__main__":
83 test_main() 130 test_main()
OLDNEW
« no previous file with comments | « Doc/library/select.rst ('k') | Modules/selectmodule.c » ('j') | no next file with comments »

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