diff options
author | Kamen Mazdrashki <kamenim@samba.org> | 2011-02-20 04:15:08 +0200 |
---|---|---|
committer | Kamen Mazdrashki <kamenim@samba.org> | 2011-02-20 23:13:11 +0200 |
commit | 348295bf8ac5f39e5be23c0a6adb8c31e64766a2 (patch) | |
tree | bc399209429b31d39d42aacd9539f00a250faee5 /source4/scripting | |
parent | adfb618ef5f7307bb5cf68185c6055375196db3a (diff) | |
download | samba-348295bf8ac5f39e5be23c0a6adb8c31e64766a2.tar.gz samba-348295bf8ac5f39e5be23c0a6adb8c31e64766a2.tar.bz2 samba-348295bf8ac5f39e5be23c0a6adb8c31e64766a2.zip |
s4/samba.tests: Extend CalledProcessError class to store STDOUT and STDERR for a failed rocess call
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/python/samba/tests/__init__.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py index d6b962c1ce..5a0e23daee 100644 --- a/source4/scripting/python/samba/tests/__init__.py +++ b/source4/scripting/python/samba/tests/__init__.py @@ -121,6 +121,19 @@ class ValidNetbiosNameTests(TestCase): self.assertFalse(samba.valid_netbios_name("*BLA")) +class BlackboxProcessError(subprocess.CalledProcessError): + """This exception is raised when a process run by check_output() returns + a non-zero exit status. Exception instance should contain + the exact exit code (S.returncode), command line (S.cmd), + process output (S.stdout) and process error stream (S.stderr)""" + def __init__(self, returncode, cmd, stdout, stderr): + super(BlackboxProcessError, self).__init__(returncode, cmd) + self.stdout = stdout + self.stderr = stderr + def __str__(self): + return "Command '%s'; exit status %d; stdout: '%s'; stderr: '%s'" % (self.cmd, self.returncode, + self.stdout, self.stderr) + class BlackboxTestCase(TestCase): """Base test case for blackbox tests.""" |