"""Test script for popen2.py
from test
.test_support
import TestSkipped
# popen2 contains its own testing routine
# which is especially useful to see if open files
# like stdin can be read successfully by a forked
print "Test popen2 module:"
if (sys
.platform
[:4] == 'beos' or sys
.platform
[:6] == 'atheos') \
and __name__
!= '__main__':
# Locks get messed up or something. Generally we're supposed
# to avoid mixing "posix" fork & exec with native threads, and
# they may be right about that after all.
raise TestSkipped
, "popen2() doesn't work during import on " + sys
.platform
# if we don't have os.popen, check that
# we have os.fork. if not, skip the test
# (by raising an ImportError)
# same test as popen2._test(), but using the os.popen*() API
print "Testing os module:"
# "more" doesn't act the same way across Windows flavors,
# sometimes adding an extra newline at the start or the
# end. So we strip whitespace off both ends for comparison.
expected
= teststr
.strip()
print "testing popen2..."
if got
.strip() != expected
:
raise ValueError("wrote %r read %r" % (teststr
, got
))
print "testing popen3..."
w
, r
, e
= os
.popen3([cmd
])
if got
.strip() != expected
:
raise ValueError("wrote %r read %r" % (teststr
, got
))
raise ValueError("unexpected %r on stderr" % (got
,))
for inst
in popen2
._active
[:]:
raise ValueError("_active not empty")