[test] Check retcode of subprocesses in devctl tests
authorDenis Laxalde <denis.laxalde@logilab.fr>
Tue, 19 Jul 2016 10:47:29 +0200
changeset 11427 7d38eb1bcd1f
parent 11426 f666f484e5f4
child 11428 7995ae2d74be
[test] Check retcode of subprocesses in devctl tests And display decoded stdout in case of failure.
cubicweb/devtools/test/unittest_devctl.py
--- a/cubicweb/devtools/test/unittest_devctl.py	Wed Jul 20 17:58:49 2016 +0200
+++ b/cubicweb/devtools/test/unittest_devctl.py	Tue Jul 19 10:47:29 2016 +0200
@@ -33,8 +33,12 @@
     return proc.returncode, stdout
 
 
-class CubicWebCtlTC(TestCase):
-    """test case for devtools commands"""
+def to_unicode(msg):
+    return msg.decode(sys.getdefaultencoding(), errors='replace')
+
+
+class DevCtlTC(TestCase):
+    """Test case for devtools commands"""
 
     if not hasattr(TestCase, 'assertItemsEqual'):
         assertItemsEqual = TestCase.assertCountEqual
@@ -47,6 +51,7 @@
         tmpdir = tempfile.mkdtemp(prefix="temp-cwctl-newcube")
         try:
             retcode, stdout = newcube(tmpdir, 'foo')
+            self.assertEqual(retcode, 0, msg=to_unicode(stdout))
             self.assertItemsEqual(os.listdir(osp.join(tmpdir, 'foo')), expected)
         finally:
             shutil.rmtree(tmpdir, ignore_errors=True)
@@ -62,7 +67,8 @@
             retcode = proc.wait()
         finally:
             shutil.rmtree(tmpdir, ignore_errors=True)
-        self.assertEqual(retcode, 0, proc.stdout.read())
+        self.assertEqual(retcode, 0,
+                         msg=to_unicode(proc.stdout.read()))
 
 
 if __name__ == '__main__':