1 from test
import test_support
7 @unittest.skipIf(sys
.platform
[:3] in ('win', 'os2', 'riscos'),
8 "can't easily test on this system")
9 class SelectTestCase(unittest
.TestCase
):
18 def test_error_conditions(self
):
19 self
.assertRaises(TypeError, select
.select
, 1, 2, 3)
20 self
.assertRaises(TypeError, select
.select
, [self
.Nope()], [], [])
21 self
.assertRaises(TypeError, select
.select
, [self
.Almost()], [], [])
22 self
.assertRaises(TypeError, select
.select
, [], [], [], "not a number")
24 def test_returned_list_identity(self
):
26 r
, w
, x
= select
.select([], [], [], 1)
27 self
.assertIsNot(r
, w
)
28 self
.assertIsNot(r
, x
)
29 self
.assertIsNot(w
, x
)
31 def test_select(self
):
32 cmd
= 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
33 p
= os
.popen(cmd
, 'r')
34 for tout
in (0, 1, 2, 4, 8, 16) + (None,)*10:
35 if test_support
.verbose
:
36 print 'timeout =', tout
37 rfd
, wfd
, xfd
= select
.select([p
], [], [], tout
)
38 if (rfd
, wfd
, xfd
) == ([], [], []):
40 if (rfd
, wfd
, xfd
) == ([p
], [], []):
42 if test_support
.verbose
:
45 if test_support
.verbose
:
49 self
.fail('Unexpected return values from select():', rfd
, wfd
, xfd
)
54 test_support
.run_unittest(SelectTestCase
)
55 test_support
.reap_children()
57 if __name__
== "__main__":