<s> """<STR_LIT>""" <EOL> from subprocess import CalledProcessError <EOL> from flocker . testtools import run_process , TestCase <EOL> class RunProcessTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def _failing_shell ( self , expression ) : <EOL> """<STR_LIT>""" <EOL> return [ b"<STR_LIT>" , b"<STR_LIT:-c>" , expression + b"<STR_LIT>" ] <EOL> def _run_fail ( self , command ) : <EOL> """<STR_LIT>""" <EOL> exception = self . assertRaises ( <EOL> CalledProcessError , <EOL> run_process , <EOL> command , <EOL> ) <EOL> return exception <EOL> def test_on_error ( self ) : <EOL> """<STR_LIT>""" <EOL> command = self . _failing_shell ( b"<STR_LIT>" ) <EOL> exception = self . _run_fail ( command ) <EOL> expected = ( <NUM_LIT:1> , command , b"<STR_LIT>" ) <EOL> actual = ( <EOL> exception . returncode , exception . cmd , exception . output <EOL> ) <EOL> self . assertEqual ( expected , actual ) <EOL> def test_exception_str ( self ) : <EOL> """<STR_LIT>""" <EOL> exception = self . _run_fail ( self . _failing_shell ( b"<STR_LIT>" ) ) <EOL> self . assertIn ( "<STR_LIT:hello>" , str ( exception ) ) </s>
