<s> from __future__ import with_statement <EOL> from easyprocess import EasyProcess , EasyProcessCheckInstalledError , EasyProcessError <EOL> from nose . tools import eq_ , timed <EOL> from unittest import TestCase <EOL> import time <EOL> class Test ( TestCase ) : <EOL> def test_call ( self ) : <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . call ( ) . return_code , <NUM_LIT:0> ) <EOL> eq_ ( EasyProcess ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . call ( ) . return_code , <NUM_LIT:0> ) <EOL> def test_check ( self ) : <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . check ( ) . return_code , <NUM_LIT:0> ) <EOL> eq_ ( EasyProcess ( [ '<STR_LIT>' , '<STR_LIT>' ] ) . check ( ) . return_code , <NUM_LIT:0> ) <EOL> self . assertRaises ( <EOL> EasyProcessError , lambda : EasyProcess ( '<STR_LIT>' ) . check ( ) ) <EOL> self . assertRaises ( <EOL> EasyProcessError , lambda : EasyProcess ( '<STR_LIT>' ) . check ( ) ) <EOL> def test_start ( self ) : <EOL> p = EasyProcess ( '<STR_LIT>' ) . start ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> eq_ ( p . stop ( ) . return_code , <NUM_LIT:0> ) <EOL> def test_start2 ( self ) : <EOL> p = EasyProcess ( '<STR_LIT>' ) . start ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> eq_ ( p . return_code , None ) <EOL> eq_ ( p . stdout , None ) <EOL> @ timed ( <NUM_LIT:1> ) <EOL> def test_start3 ( self ) : <EOL> p = EasyProcess ( '<STR_LIT>' ) . start ( ) <EOL> eq_ ( p . return_code , None ) <EOL> def test_alive ( self ) : <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . is_alive ( ) , False ) <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . start ( ) . is_alive ( ) , True ) <EOL> eq_ ( EasyProcess ( <EOL> '<STR_LIT>' ) . start ( ) . stop ( ) . is_alive ( ) , False ) <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . call ( ) . is_alive ( ) , False ) <EOL> def test_std ( self ) : <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . call ( ) . stdout , '<STR_LIT:hello>' ) <EOL> def test_wait ( self ) : <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . wait ( ) . return_code , None ) <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . wait ( ) . stdout , None ) <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . start ( ) . wait ( ) . return_code , <NUM_LIT:0> ) <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . start ( ) . wait ( ) . stdout , '<STR_LIT:hello>' ) <EOL> def test_wrap ( self ) : <EOL> def f ( ) : <EOL> return EasyProcess ( '<STR_LIT>' ) . call ( ) . stdout <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . wrap ( f ) ( ) , '<STR_LIT>' ) <EOL> def test_with ( self ) : <EOL> with EasyProcess ( '<STR_LIT>' ) as x : <EOL> self . assertTrue ( x . is_alive ( ) ) <EOL> self . assertNotEquals ( x . return_code , <NUM_LIT:0> ) <EOL> self . assertFalse ( x . is_alive ( ) ) <EOL> def test_install ( self ) : <EOL> EasyProcess ( '<STR_LIT>' ) . check_installed ( ) <EOL> self . assertRaises ( EasyProcessCheckInstalledError , <EOL> lambda : EasyProcess ( '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> ubuntu_package = '<STR_LIT>' ) . check_installed ( ) ) <EOL> EasyProcess ( '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> ubuntu_package = '<STR_LIT>' ) . check_installed ( ) <EOL> def test_parse ( self ) : <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . cmd , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . cmd , [ '<STR_LIT>' , '<STR_LIT:abc>' ] ) <EOL> eq_ ( EasyProcess ( '<STR_LIT>' ) . cmd , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def test_stop ( self ) : <EOL> p = EasyProcess ( '<STR_LIT>' ) . start ( ) <EOL> time . sleep ( <NUM_LIT> ) <EOL> eq_ ( p . stop ( ) . return_code , <NUM_LIT:0> ) <EOL> eq_ ( p . stop ( ) . return_code , <NUM_LIT:0> ) <EOL> eq_ ( p . stop ( ) . return_code , <NUM_LIT:0> ) </s>
