2 """Test script for popen2.py
8 # popen2 contains its own testing routine
9 # which is especially useful to see if open files
10 # like stdin can be read successfully by a forked
14 print "Test popen2 module:"
18 # if we don't have os.popen, check that
19 # we have os.fork. if not, skip the test
20 # (by raising an ImportError)
27 # same test as popen2._test(), but using the os.popen*() API
28 print "Testing os module:"
34 # "more" doesn't act the same way across Windows flavors,
35 # sometimes adding an extra newline at the start or the
36 # end. So we strip whitespace off both ends for comparison.
37 expected
= teststr
.strip()
38 print "testing popen2..."
43 if got
.strip() != expected
:
44 raise ValueError("wrote %s read %s" % (`teststr`
, `got`
))
45 print "testing popen3..."
47 w
, r
, e
= os
.popen3([cmd
])
49 w
, r
, e
= os
.popen3(cmd
)
53 if got
.strip() != expected
:
54 raise ValueError("wrote %s read %s" % (`teststr`
, `got`
))
57 raise ValueError("unexected %s on stderr" % `got`
)
58 for inst
in popen2
._active
[:]:
61 raise ValueError("_active not empty")