s4/samba.tests: Raise BlackboxProcessError exception in case check_output method...
authorKamen Mazdrashki <kamenim@samba.org>
Sun, 20 Feb 2011 02:17:25 +0000 (04:17 +0200)
committerKamen Mazdrashki <kamenim@samba.org>
Sun, 20 Feb 2011 21:13:12 +0000 (23:13 +0200)
This way the caller gets the chance to receive STDOUT and STDERR for
a failed process.
We may use this info to check if a process has failed properly,
e.g. with expected output

source4/scripting/python/samba/tests/__init__.py

index 5a0e23daee4f9950ec885d5676ec1b0af1d133bf..58e4130998026cd9f7479ec95eb66f4f446ae3e1 100644 (file)
@@ -151,10 +151,10 @@ class BlackboxTestCase(TestCase):
 
     def check_output(self, line):
         line = self._make_cmdline(line)
-        p = subprocess.Popen(line, stdout=subprocess.PIPE, shell=True, close_fds=True)
+        p = subprocess.Popen(line, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, close_fds=True)
         retcode = p.wait()
         if retcode:
-            raise subprocess.CalledProcessError(retcode, line)
+            raise BlackboxProcessError(retcode, line, p.stdout.read(), p.stderr.read())
         return p.stdout.read()
 
 def connect_samdb(samdb_url, lp=None, session_info=None, credentials=None,