Skip to content

Commit 2c78ca7

Browse files
authored
Merge pull request #244 from lzhu666/master
Support utf8 display
2 parents 3e1f812 + 3d5e334 commit 2c78ca7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pytest_html/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(self, logfile, config):
104104

105105
class TestResult:
106106
def __init__(self, outcome, report, logfile, config):
107-
self.test_id = report.nodeid
107+
self.test_id = report.nodeid.encode("utf-8").decode("unicode_escape")
108108
if getattr(report, "when", "call") != "call":
109109
self.test_id = "::".join([report.nodeid, report.when])
110110
self.time = getattr(report, "duration", 0.0)

testing/test_pytest_html.py

+13
Original file line numberDiff line numberDiff line change
@@ -786,3 +786,16 @@ def test_css_invalid_no_html(self, testdir):
786786
testdir.makepyfile("def test_pass(): pass")
787787
result = testdir.runpytest("--css", "style.css")
788788
assert result.ret == 0
789+
790+
def test_report_display_utf8(self, testdir):
791+
testdir.makepyfile(
792+
"""
793+
import pytest
794+
@pytest.mark.parametrize("caseName,input,expected", [('测试用例名称', '6*6', 36)])
795+
def test_eval(caseName, input, expected):
796+
assert eval(input) == expected
797+
"""
798+
)
799+
result, html = run(testdir)
800+
assert result.ret == 0
801+
assert r'\u6d4b\u8bd5\u7528\u4f8b\u540d\u79f0' not in html

0 commit comments

Comments
 (0)