<s> """<STR_LIT>""" <EOL> import unittest <EOL> from test import support <EOL> import os , sys <EOL> python = sys . executable <EOL> if '<STR_LIT:U+0020>' in python : <EOL> python = '<STR_LIT:">' + python + '<STR_LIT:">' <EOL> class PopenTest ( unittest . TestCase ) : <EOL> def _do_test_commandline ( self , cmdline , expected ) : <EOL> cmd = '<STR_LIT>' <EOL> cmd = cmd % ( python , cmdline ) <EOL> with os . popen ( cmd ) as p : <EOL> data = p . read ( ) <EOL> got = eval ( data ) [ <NUM_LIT:1> : ] <EOL> self . assertEqual ( got , expected ) <EOL> def test_popen ( self ) : <EOL> self . assertRaises ( TypeError , os . popen ) <EOL> self . _do_test_commandline ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT:foo>" , "<STR_LIT:bar>" ] <EOL> ) <EOL> self . _do_test_commandline ( <EOL> '<STR_LIT>' , <EOL> [ "<STR_LIT:foo>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> ) <EOL> self . _do_test_commandline ( <EOL> '<STR_LIT>' , <EOL> [ "<STR_LIT:foo>" , '<STR_LIT>' , "<STR_LIT:bar>" ] <EOL> ) <EOL> support . reap_children ( ) <EOL> def test_return_code ( self ) : <EOL> self . assertEqual ( os . popen ( "<STR_LIT>" ) . close ( ) , None ) <EOL> if os . name == '<STR_LIT>' : <EOL> self . assertEqual ( os . popen ( "<STR_LIT>" ) . close ( ) , <NUM_LIT> ) <EOL> else : <EOL> self . assertEqual ( os . popen ( "<STR_LIT>" ) . close ( ) , <NUM_LIT> << <NUM_LIT:8> ) <EOL> def test_contextmanager ( self ) : <EOL> with os . popen ( "<STR_LIT>" ) as f : <EOL> self . assertEqual ( f . read ( ) , "<STR_LIT>" ) <EOL> def test_iterating ( self ) : <EOL> with os . popen ( "<STR_LIT>" ) as f : <EOL> self . assertEqual ( list ( f ) , [ "<STR_LIT>" ] ) <EOL> def test_main ( ) : <EOL> support . run_unittest ( PopenTest ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
