pytest-html
pytest-html copied to clipboard
Multi byte character method name is garbled
issue
When use unicode in test method,
def test_あいうえお(self):
print('かきくけこ')
I got garbled text (mojibake) in html reports.
test_ããããã
reason
Method name ( report.nodeid ) is encoded as utf-8 and decoded as unicode_escape .
src/pytest_html/result.py
self.test_id = report.nodeid.encode("utf-8").decode("unicode_escape")
Multi byte character as utf-8 is different same one as unicode_escape.
>>> print('abcdeあいうえお'.encode("utf-8"))
b'abcde\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a'
>>> print('abcdeあいうえお'.encode("unicode_escape"))
b'abcde\\u3042\\u3044\\u3046\\u3048\\u304a'