utils: rename RunCommandError to CalledProcessError

The Python 3.6 subprocess uses the |CalledProcessError| name.
Also adjust all of its attributes to match.

Bug: None
Test: unittests pass
Change-Id: I2474e7e74b259b4082824fe573337329a94bc751
diff --git a/rh/utils_unittest.py b/rh/utils_unittest.py
index 9cacb84..8f50998 100755
--- a/rh/utils_unittest.py
+++ b/rh/utils_unittest.py
@@ -65,72 +65,69 @@
         self.assertEqual('1h6m40.300s', rh.utils.timedelta_str(delta))
 
 
-class CommandResultTests(unittest.TestCase):
-    """Verify behavior of CommandResult object."""
+class CompletedProcessTests(unittest.TestCase):
+    """Verify behavior of CompletedProcess object."""
 
     def test_empty_cmdstr(self):
         """Check cmdstr with an empty command."""
-        result = rh.utils.CommandResult(cmd=[])
+        result = rh.utils.CompletedProcess(args=[])
         self.assertEqual('', result.cmdstr)
 
     def test_basic_cmdstr(self):
         """Check cmdstr with a basic command command."""
-        result = rh.utils.CommandResult(cmd=['ls', 'a b'])
+        result = rh.utils.CompletedProcess(args=['ls', 'a b'])
         self.assertEqual("ls 'a b'", result.cmdstr)
 
     def test_str(self):
         """Check str() handling."""
         # We don't enforce much, just that it doesn't crash.
-        result = rh.utils.CommandResult()
+        result = rh.utils.CompletedProcess()
         self.assertNotEqual('', str(result))
-        result = rh.utils.CommandResult(cmd=[])
+        result = rh.utils.CompletedProcess(args=[])
         self.assertNotEqual('', str(result))
 
     def test_repr(self):
         """Check repr() handling."""
         # We don't enforce much, just that it doesn't crash.
-        result = rh.utils.CommandResult()
+        result = rh.utils.CompletedProcess()
         self.assertNotEqual('', repr(result))
-        result = rh.utils.CommandResult(cmd=[])
+        result = rh.utils.CompletedProcess(args=[])
         self.assertNotEqual('', repr(result))
 
 
-class RunCommandErrorTests(unittest.TestCase):
-    """Verify behavior of RunCommandError object."""
-
-    def setUp(self):
-        self.result = rh.utils.CommandResult(cmd=['mycmd'])
+class CalledProcessErrorTests(unittest.TestCase):
+    """Verify behavior of CalledProcessError object."""
 
     def test_basic(self):
         """Basic test we can create a normal instance."""
-        rh.utils.RunCommandError('msg', self.result)
-        rh.utils.RunCommandError('msg', self.result, exception=Exception('bad'))
+        rh.utils.CalledProcessError(0, ['mycmd'])
+        rh.utils.CalledProcessError(1, ['mycmd'], exception=Exception('bad'))
 
     def test_stringify(self):
         """Check stringify() handling."""
         # We don't assert much so we leave flexibility in changing format.
-        err = rh.utils.RunCommandError('msg', self.result)
+        err = rh.utils.CalledProcessError(0, ['mycmd'])
         self.assertIn('mycmd', err.stringify())
-        err = rh.utils.RunCommandError('msg', self.result,
-                                       exception=Exception('bad'))
+        err = rh.utils.CalledProcessError(
+            0, ['mycmd'], exception=Exception('bad'))
         self.assertIn('mycmd', err.stringify())
 
     def test_str(self):
         """Check str() handling."""
         # We don't assert much so we leave flexibility in changing format.
-        err = rh.utils.RunCommandError('msg', self.result)
+        err = rh.utils.CalledProcessError(0, ['mycmd'])
         self.assertIn('mycmd', str(err))
-        err = rh.utils.RunCommandError('msg', self.result,
-                                       exception=Exception('bad'))
+        err = rh.utils.CalledProcessError(
+            0, ['mycmd'], exception=Exception('bad'))
         self.assertIn('mycmd', str(err))
 
     def test_repr(self):
         """Check repr() handling."""
         # We don't assert much so we leave flexibility in changing format.
-        err = rh.utils.RunCommandError('msg', self.result)
+        err = rh.utils.CalledProcessError(0, ['mycmd'])
         self.assertNotEqual('', repr(err))
-        err = rh.utils.RunCommandError('msg', self.result,
-                                       exception=Exception('bad'))
+        err = rh.utils.CalledProcessError(
+            0, ['mycmd'], exception=Exception('bad'))
         self.assertNotEqual('', repr(err))
 
 
@@ -184,32 +181,32 @@
         """Simple basic test."""
         ret = rh.utils.run(['true'])
         self.assertEqual('true', ret.cmdstr)
-        self.assertIsNone(ret.output)
-        self.assertIsNone(ret.error)
+        self.assertIsNone(ret.stdout)
+        self.assertIsNone(ret.stderr)
 
     def test_stdout_capture(self):
         """Verify output capturing works."""
         ret = rh.utils.run(['echo', 'hi'], redirect_stdout=True)
-        self.assertEqual('hi\n', ret.output)
-        self.assertIsNone(ret.error)
+        self.assertEqual('hi\n', ret.stdout)
+        self.assertIsNone(ret.stderr)
 
     def test_stderr_capture(self):
         """Verify stderr capturing works."""
         ret = rh.utils.run(['sh', '-c', 'echo hi >&2'], redirect_stderr=True)
-        self.assertIsNone(ret.output)
-        self.assertEqual('hi\n', ret.error)
+        self.assertIsNone(ret.stdout)
+        self.assertEqual('hi\n', ret.stderr)
 
     def test_stdout_utf8(self):
         """Verify reading UTF-8 data works."""
         ret = rh.utils.run(['printf', r'\xc3\x9f'], redirect_stdout=True)
-        self.assertEqual(u'ß', ret.output)
-        self.assertIsNone(ret.error)
+        self.assertEqual(u'ß', ret.stdout)
+        self.assertIsNone(ret.stderr)
 
     def test_stdin_utf8(self):
         """Verify writing UTF-8 data works."""
         ret = rh.utils.run(['cat'], redirect_stdout=True, input=u'ß')
-        self.assertEqual(u'ß', ret.output)
-        self.assertIsNone(ret.error)
+        self.assertEqual(u'ß', ret.stdout)
+        self.assertIsNone(ret.stderr)
 
 
 if __name__ == '__main__':