From 81457dea939e0f05021dc430dd2398e8ce2ae3db Mon Sep 17 00:00:00 2001 From: debugtalk Date: Sun, 25 Feb 2018 23:15:32 +0800 Subject: [PATCH] bugfix open and write file: make compatible with Python 2.7 --- httprunner/report.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httprunner/report.py b/httprunner/report.py index 18efea1f..a6e72f7a 100644 --- a/httprunner/report.py +++ b/httprunner/report.py @@ -1,3 +1,4 @@ +import io import os import time import unittest @@ -141,7 +142,7 @@ class HtmlTestResult(unittest.TextTestResult): os.makedirs(report_dir_path) report_path = os.path.join(report_dir_path, html_report_name) - with open(report_path, 'w', encoding='utf-8') as fp: + with io.open(report_path, 'w', encoding='utf-8') as fp: rendered_content = Template(template_content).render(summary) fp.write(rendered_content)