From 591b4da2c66dccb1fee36e5ac271cf2e834f66f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Tue, 18 Sep 2018 12:50:59 +0200 Subject: [PATCH] selftests: Add CmdResul.__str__ selftest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukáš Doktor --- selftests/unit/test_utils_process.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/selftests/unit/test_utils_process.py b/selftests/unit/test_utils_process.py index 7feb02d4..6cdf0872 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)) -- GitLab