def test_repr(self): """repr contains output, error and code""" procerr = shell.ProcessError(13, "myout42", "myerr42") stringified = repr(procerr) self.assertIn('13', stringified) self.assertIn('myout42', stringified) self.assertIn('myerr42', stringified)
def test_trace(self): """traceback has args""" try: raise shell.ProcessError(13, "myout8080", "myerr8080") except shell.ProcessError: trace = traceback.format_exc() stringified = trace.splitlines()[-2] self.assertIn('13', stringified) self.assertIn('myout8080', stringified) self.assertIn('myerr8080', stringified)
def test_failure(self): """autoexit_code wrapping a ProcessError raise exits""" with self.assertRaises(SystemExit): with shell.autoexit_code(): raise shell.ProcessError(13)
def test_output(self): """output attribtue is set to passed-in value""" self.assertEqual(shell.ProcessError(13, "woo").output, "woo")
def test_returncode(self): """returncode attribtue is set to passed-in value""" self.assertEqual(shell.ProcessError(13).returncode, 13)