From 4e1e72173c0704f0c7b9e494feec12ba74a40190 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 20 Sep 2017 14:59:32 +0800 Subject: [PATCH] bugfix: UnicodeEncodeError when value is in Chinese --- ate/utils.py | 7 ++++--- tests/test_task.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ate/utils.py b/ate/utils.py index b7c66508..9b732c3f 100644 --- a/ate/utils.py +++ b/ate/utils.py @@ -365,10 +365,11 @@ def print_output(output): return print("\n================== Output ==================") - print('{:<10}: {:<}'.format("Variable", "Value")) - print('{:<10}: {:<}'.format("--------", "-----")) + print('{:<16}: {:<}'.format("Variable", "Value")) + print('{:<16}: {:<}'.format("--------", "-----")) for variable, value in output.items(): - print('{:<10}: {:<}'.format(variable, value)) + print('{:<16}: {:<}'.format( + variable.encode("utf-8"), value.encode("utf-8"))) print("============================================\n") diff --git a/tests/test_task.py b/tests/test_task.py index d62f369e..c30a01d2 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -25,7 +25,7 @@ class TestTask(ApiServerUnittest): def test_create_task(self): testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo_testset_variables.yml') - task_suite = task.create_task(testcase_file_path) + task_suite = task.TaskSuite(testcase_file_path) self.assertEqual(task_suite.countTestCases(), 3) for suite in task_suite: for testcase in suite: