<s> from __future__ import print_function <EOL> from __future__ import unicode_literals <EOL> from __future__ import division <EOL> import unittest <EOL> from pycopia import proctools <EOL> from pycopia import crontab <EOL> from pycopia import expect <EOL> from pycopia import netcat <EOL> from pycopia import proctools <EOL> from pycopia import rsynclib <EOL> from pycopia import sshlib <EOL> from pycopia import sudo <EOL> def _sub_function ( ) : <EOL> from pycopia import scheduler <EOL> scheduler . sleep ( <NUM_LIT:5> ) <EOL> return None <EOL> def _co_function ( ) : <EOL> import sys <EOL> from pycopia import scheduler <EOL> sys . stdout . write ( "<STR_LIT>" ) <EOL> scheduler . sleep ( <NUM_LIT:5> ) <EOL> return None <EOL> class ProcessTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> pass <EOL> def test_spawnpipe ( self ) : <EOL> ls = proctools . spawnpipe ( "<STR_LIT>" ) <EOL> files = ls . read ( ) <EOL> self . assertTrue ( files ) <EOL> self . assertFalse ( ls . readerr ( ) ) <EOL> ls . close ( ) <EOL> es = ls . wait ( ) <EOL> self . assertTrue ( es ) <EOL> def test_lserror ( self ) : <EOL> ls = proctools . spawnpipe ( "<STR_LIT>" , merge = <NUM_LIT:0> ) <EOL> print ( ls . read ( ) ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( ls . readerr ( ) ) <EOL> ls . close ( ) <EOL> ls . wait ( ) <EOL> es = ls . stat ( ) <EOL> self . assertFalse ( es ) <EOL> def test_readaline ( self ) : <EOL> lspm = proctools . spawnpipe ( "<STR_LIT>" ) <EOL> lines = lspm . readlines ( ) <EOL> self . assertTrue ( lines ) <EOL> lspm . close ( ) <EOL> es = lspm . stat ( ) <EOL> self . assertTrue ( es ) <EOL> def test_subprocess ( self ) : <EOL> sub = proctools . subprocess ( _sub_function ) <EOL> es = sub . wait ( ) <EOL> self . assertTrue ( es ) <EOL> def test_coprocess ( self ) : <EOL> sub = proctools . coprocess ( _co_function ) <EOL> line = sub . readline ( ) <EOL> es = sub . wait ( ) <EOL> self . assertTrue ( es ) <EOL> def XXXtest_sudo ( self ) : <EOL> pw = sudo . getpw ( ) <EOL> proc = sudo . sudo ( "<STR_LIT>" , password = pw ) <EOL> print ( proc . read ( ) ) <EOL> print ( repr ( proc . readerr ( ) ) ) <EOL> proc . wait ( ) <EOL> sudo . sudo_reset ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
