Skip to content

Multi byte character method name is garbled #501

Open

Description

@kannkyo

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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions