2 """Test script for popen2.py
8 from test_support
import TestSkipped
10 # popen2 contains its own testing routine
11 # which is especially useful to see if open files
12 # like stdin can be read successfully by a forked
16 print "Test popen2 module:"
17 if sys
.platform
[:4] == 'beos' and __name__
!= '__main__':
18 # Locks get messed up or something. Generally we're supposed
19 # to avoid mixing "posix" fork & exec with native threads, and
20 # they may be right about that after all.
21 raise TestSkipped
, "popen2() doesn't work during import on BeOS"
25 # if we don't have os.popen, check that
26 # we have os.fork. if not, skip the test
27 # (by raising an ImportError)
34 # same test as popen2._test(), but using the os.popen*() API
35 print "Testing os module:"
41 # "more" doesn't act the same way across Windows flavors,
42 # sometimes adding an extra newline at the start or the
43 # end. So we strip whitespace off both ends for comparison.
44 expected
= teststr
.strip()
45 print "testing popen2..."
50 if got
.strip() != expected
:
51 raise ValueError("wrote %s read %s" % (`teststr`
, `got`
))
52 print "testing popen3..."
54 w
, r
, e
= os
.popen3([cmd
])
56 w
, r
, e
= os
.popen3(cmd
)
60 if got
.strip() != expected
:
61 raise ValueError("wrote %s read %s" % (`teststr`
, `got`
))
64 raise ValueError("unexected %s on stderr" % `got`
)
65 for inst
in popen2
._active
[:]:
68 raise ValueError("_active not empty")