From f251cea504517852ca8b8095a8edb79a15d542c1 Mon Sep 17 00:00:00 2001 From: "Andy.Yang" <52188094+lzhu666@users.noreply.github.com> Date: Fri, 11 Oct 2019 11:52:35 +0800 Subject: [PATCH 1/2] Update plugin.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support Chinese display [before]: TestForSyncProduct::test_1_valueValid[test Case Name-add] TestForSyncProduct::test_2_valueValid[\u6d4b\u8bd5\u7528\u4f8b\u540d\u79f0-update] [now]: TestForSyncProduct::test_1_valueValid[test Case Name-add] TestForSyncProduct::test_2_valueValid[测试用例名称-update] --- pytest_html/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest_html/plugin.py b/pytest_html/plugin.py index 7e14df5d..73aa0add 100644 --- a/pytest_html/plugin.py +++ b/pytest_html/plugin.py @@ -103,7 +103,7 @@ def __init__(self, logfile, config): class TestResult: def __init__(self, outcome, report, logfile, config): - self.test_id = report.nodeid + self.test_id = report.nodeid.encode("utf-8").decode("unicode_escape") if getattr(report, "when", "call") != "call": self.test_id = "::".join([report.nodeid, report.when]) self.time = getattr(report, "duration", 0.0) From 618af9e072db53841110bbe2f64627ab13a6f30d Mon Sep 17 00:00:00 2001 From: "Andy.Yang" <52188094+lzhu666@users.noreply.github.com> Date: Tue, 5 Nov 2019 13:44:08 +0800 Subject: [PATCH 2/2] Support utf8 display --- testing/test_pytest_html.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/testing/test_pytest_html.py b/testing/test_pytest_html.py index 1fe847e6..83987f03 100644 --- a/testing/test_pytest_html.py +++ b/testing/test_pytest_html.py @@ -784,3 +784,16 @@ def test_css_invalid_no_html(self, testdir): testdir.makepyfile("def test_pass(): pass") result = testdir.runpytest("--css", "style.css") assert result.ret == 0 + + def test_report_display_utf8(self, testdir): + testdir.makepyfile( + """ + import pytest + @pytest.mark.parametrize("caseName,input,expected", [('测试用例名称', '6*6', 36)]) + def test_eval(caseName, input, expected): + assert eval(input) == expected + """ + ) + result, html = run(testdir) + assert result.ret == 0 + assert r'\u6d4b\u8bd5\u7528\u4f8b\u540d\u79f0' not in html