Skip to content

Support utf8 display #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytest_html/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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)
Expand Down
13 changes: 13 additions & 0 deletions testing/test_pytest_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,3 +786,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