annotate Lib/test/test_select.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents ca123f240ba9
children 5e31d381fa47
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # Testing select module
5327
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
2 from test_support import verbose
4691
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
3 import select
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
4 import os
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
5
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
6 # test some known error conditions
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
7 try:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
8 rfd, wfd, xfd = select.select(1, 2, 3)
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
9 except TypeError:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
10 pass
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
11 else:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
12 print 'expected TypeError exception not raised'
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
13
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
14 class Nope:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
15 pass
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
16
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
17 class Almost:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
18 def fileno(self):
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
19 return 'fileno'
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
20
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
21 try:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
22 rfd, wfd, xfd = select.select([Nope()], [], [])
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
23 except TypeError:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
24 pass
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
25 else:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
26 print 'expected TypeError exception not raised'
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
27
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
28 try:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
29 rfd, wfd, xfd = select.select([Almost()], [], [])
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
30 except TypeError:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
31 pass
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
32 else:
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
33 print 'expected TypeError exception not raised'
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
34
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 def test():
5327
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
37 import sys
5517
ca123f240ba9 Fix sys.platform test -- on Win, it is 'win32', not 'win'.
Guido van Rossum <guido@python.org>
parents: 5327
diff changeset
38 if sys.platform[:3] in ('win', 'mac'):
5327
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
39 if verbose:
5517
ca123f240ba9 Fix sys.platform test -- on Win, it is 'win32', not 'win'.
Guido van Rossum <guido@python.org>
parents: 5327
diff changeset
40 print "Can't test select easily on", sys.platform
5327
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
41 return
4691
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
42 cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 p = os.popen(cmd, 'r')
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 for tout in (0, 1, 2, 4, 8, 16) + (None,)*10:
5327
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
45 if verbose:
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
46 print 'timeout =', tout
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 rfd, wfd, xfd = select.select([p], [], [], tout)
4691
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
48 ## print rfd, wfd, xfd
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 if (rfd, wfd, xfd) == ([], [], []):
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 continue
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 if (rfd, wfd, xfd) == ([p], [], []):
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 line = p.readline()
5327
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
53 if verbose:
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
54 print `line`
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 if not line:
5327
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
56 if verbose:
152b2827a1a0 Soft failure for Win32 and Mac platforms. Less output unless verbose.
Guido van Rossum <guido@python.org>
parents: 4959
diff changeset
57 print 'EOF'
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 break
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 continue
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 print 'Heh?'
4959
89d07795fd69 test(): close the pipe, just to shut up Purify.
Barry Warsaw <barry@python.org>
parents: 4691
diff changeset
61 p.close()
1407
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
62
b9fcfb99a3e5 * test_select.py: (some) tests for built-in select module
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 test()
4691
8015c5549309 A test of the select module that is actually reproduceable!
Barry Warsaw <barry@python.org>
parents: 1416
diff changeset
64