diff --git a/selftests/unit/test_utils_process.py b/selftests/unit/test_utils_process.py index 7feb02d414833c543b9d68a870bda870a8070e90..6cdf087297d0346be2da67d22a950279b27fef1d 100644 --- a/selftests/unit/test_utils_process.py +++ b/selftests/unit/test_utils_process.py @@ -281,6 +281,20 @@ class MiscProcessTests(unittest.TestCase): class CmdResultTests(unittest.TestCase): + def test_nasty_str(self): + result = process.CmdResult("ls", b"unicode_follows: \xc5\xa1", + b"cp1250 follows: \xfd", 1, 2, 3, + "wrong_encoding") + if PY2: + prefix = '' + else: + prefix = 'b' + self.assertEqual(str(result), "command: 'ls'\nexit_status: 1" + "\nduration: 2\ninterrupted: False\npid: " + "3\nencoding: 'wrong_encoding'\nstdout: " + "%s'unicode_follows: \\xc5\\xa1'\nstderr: " + "%s'cp1250 follows: \\xfd'" % (prefix, prefix)) + def test_cmd_result_stdout_stderr_bytes(self): result = process.CmdResult() self.assertTrue(isinstance(result.stdout, bytes))