From 3b5a5edb5fd51f899e4acd931b71f8d0a59a84f8 Mon Sep 17 00:00:00 2001 From: dongfangtianyu <7629022+dongfangtianyu@users.noreply.github.com> Date: Fri, 7 Aug 2020 15:19:45 +0800 Subject: [PATCH] template support utf-8 character --- HtmlTestRunner/result.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HtmlTestRunner/result.py b/HtmlTestRunner/result.py index 96fb431..2c4130f 100644 --- a/HtmlTestRunner/result.py +++ b/HtmlTestRunner/result.py @@ -20,14 +20,14 @@ def load_template(template): file = None try: if template: - with open(template, "r") as f: + with open(template, "r", encoding="utf-8") as f: file = f.read() except Exception as err: print("Error: Your Template wasn't loaded", err, "Loading Default Template", sep="\n") finally: if not file: - with open(DEFAULT_TEMPLATE, "r") as f: + with open(DEFAULT_TEMPLATE, "r", encoding="utf-8") as f: file = f.read() return file @@ -400,7 +400,7 @@ def generate_file(self, testRunner, report_name, report): path_file = os.path.abspath(os.path.join(dir_to, report_name)) self.stream.writeln(os.path.relpath(path_file)) self.report_files.append(path_file) - with open(path_file, 'w') as report_file: + with open(path_file, 'w', encoding="utf-8") as report_file: report_file.write(report) def _exc_info_to_string(self, err, test):