<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> from test . test_support import TestSkipped , reap_children <EOL> def main ( ) : <EOL> print "<STR_LIT>" <EOL> if ( sys . platform [ : <NUM_LIT:4> ] == '<STR_LIT>' or sys . platform [ : <NUM_LIT:6> ] == '<STR_LIT>' ) and __name__ != '<STR_LIT:__main__>' : <EOL> raise TestSkipped , "<STR_LIT>" + sys . platform <EOL> try : <EOL> from os import popen <EOL> except ImportError : <EOL> from os import fork <EOL> import popen2 <EOL> popen2 . _test ( ) <EOL> def _test ( ) : <EOL> print "<STR_LIT>" <EOL> import popen2 <EOL> popen2 . _cleanup ( ) <EOL> assert not popen2 . _active , "<STR_LIT>" + repr ( [ c . cmd for c in popen2 . _active ] ) <EOL> cmd = "<STR_LIT>" <EOL> teststr = "<STR_LIT>" <EOL> if os . name == "<STR_LIT>" : <EOL> cmd = "<STR_LIT>" <EOL> expected = teststr . strip ( ) <EOL> print "<STR_LIT>" <EOL> w , r = os . popen2 ( cmd ) <EOL> w . write ( teststr ) <EOL> w . close ( ) <EOL> got = r . read ( ) <EOL> if got . strip ( ) != expected : <EOL> raise ValueError ( "<STR_LIT>" % ( teststr , got ) ) <EOL> print "<STR_LIT>" <EOL> try : <EOL> w , r , e = os . popen3 ( [ cmd ] ) <EOL> except : <EOL> w , r , e = os . popen3 ( cmd ) <EOL> w . write ( teststr ) <EOL> w . close ( ) <EOL> got = r . read ( ) <EOL> if got . strip ( ) != expected : <EOL> raise ValueError ( "<STR_LIT>" % ( teststr , got ) ) <EOL> got = e . read ( ) <EOL> if got : <EOL> raise ValueError ( "<STR_LIT>" % ( got , ) ) <EOL> for inst in popen2 . _active [ : ] : <EOL> inst . wait ( ) <EOL> popen2 . _cleanup ( ) <EOL> if popen2 . _active : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> print "<STR_LIT>" <EOL> main ( ) <EOL> _test ( ) <EOL> reap_children ( ) </s>
