Unittest - Readability and information improvements with test failures

This commit is contained in:
Renato Alves 2014-07-24 15:52:24 +01:00
parent e070500d26
commit 07cd033cbc
2 changed files with 30 additions and 11 deletions

View file

@ -5,13 +5,18 @@ import signal
class CommandError(Exception):
def __init__(self, cmd, code, out, err, msg=None):
if msg is None:
msg_suffix = (
"\n*** Start STDOUT ***\n{2}\n*** End STDOUT ***\n"
"\n*** Start STDERR ***\n{3}\n*** End STDERR ***\n"
)
if code == signal.SIGABRT:
self.msg = ("Command '{0}' was aborted, likely due to not "
"finishing in due time. The exit code was "
"'{1}':\nStdout: '{2}'\nStderr: '{3}'")
"finishing in due time. The exit code was '{1}'.\n"
) + msg_suffix
else:
self.msg = ("Command '{0}' finished with unexpected exit code "
"'{1}':\nStdout: '{2}'\nStderr: '{3}'")
self.msg = ("Command '{0}' finished with unexpected exit "
"code '{1}'.\n"
) + msg_suffix
else:
self.msg = msg