diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2018-02-22 14:19:11 +1300 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2018-02-24 18:20:14 +0100 |
commit | be96147e6966ac7b68418e1889e55b38874c1561 (patch) | |
tree | 6e9a1d3146f16f77d35efde16abf335e98203c48 /python | |
parent | 1ed693423d7a30c3810ddc1b6f052d376c8cd4e7 (diff) | |
download | samba-be96147e6966ac7b68418e1889e55b38874c1561.tar.gz |
text/python/blackbox: allow optional message in ProcessError
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/tests/__init__.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index b6293dff757..935a0873303 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -328,15 +328,20 @@ class BlackboxProcessError(Exception): (S.stderr) """ - def __init__(self, returncode, cmd, stdout, stderr): + def __init__(self, returncode, cmd, stdout, stderr, msg=None): self.returncode = returncode self.cmd = cmd self.stdout = stdout self.stderr = stderr + self.msg = msg def __str__(self): - return "Command '%s'; exit status %d; stdout: '%s'; stderr: '%s'" % (self.cmd, self.returncode, - self.stdout, self.stderr) + s = ("Command '%s'; exit status %d; stdout: '%s'; stderr: '%s'" % + (self.cmd, self.returncode, self.stdout, self.stderr)) + if self.msg is not None: + s = "%s; message: %s" % (s, self.msg) + + return s class BlackboxTestCase(TestCaseInTempDir): """Base test case for blackbox tests.""" @@ -349,10 +354,10 @@ class BlackboxTestCase(TestCaseInTempDir): line = " ".join(parts) return line - def check_run(self, line): - self.check_exit_code(line, 0) + def check_run(self, line, msg=None): + self.check_exit_code(line, 0, msg=msg) - def check_exit_code(self, line, expected): + def check_exit_code(self, line, expected, msg=None): line = self._make_cmdline(line) p = subprocess.Popen(line, stdout=subprocess.PIPE, @@ -364,7 +369,8 @@ class BlackboxTestCase(TestCaseInTempDir): raise BlackboxProcessError(retcode, line, stdoutdata, - stderrdata) + stderrdata, + msg) def check_output(self, line): line = self._make_cmdline(line) |