Skip to content
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

pytest terminal transcoding unicode conflict with report #450

Open
cxdtotsj opened this issue Apr 12, 2021 · 9 comments
Open

pytest terminal transcoding unicode conflict with report #450

cxdtotsj opened this issue Apr 12, 2021 · 9 comments

Comments

@cxdtotsj
Copy link

cxdtotsj commented Apr 12, 2021

I use pytest.mark.parametrize, then conftest.py exists code:

def pytest_collection_modifyitems(items):
    for item in items:
        item.name = item.name.encode("utf-8").decode("unicode_escape")
        item._nodeid = item.nodeid.encode("utf-8").decode("unicode_escape")

if I execute pytest -s -v --capture=sys --html=report/test.html .\test_01.py,

image

html report displayed title is garbled,but if pytest-html=2.0.0, there is no such problem.

this is pytest-ntml=2.0.0:

  class TestResult:
      def __init__(self, outcome, report, logfile, config):
          self.test_id = report.nodeid

this is pytest-html=3.x.x:

class TestResult:
    def __init__(self, outcome, report, logfile, config):
        self.test_id = report.nodeid.encode("utf-8").decode("unicode_escape")

If i not run the hooks function pytest_collection_modifyitems, terminal output is unicode. If i run hooks, pytest-html case title is Garbled.

@wu-clan
Copy link

wu-clan commented Apr 27, 2022

Is there a good solution to this problem at present?

@BeyondEvil
Copy link
Contributor

Unfortunately not. At least not one that I'm aware of.

We plan to address this in next-gen however.

@wu-clan
Copy link

wu-clan commented Apr 28, 2022

Unfortunately not. At least not one that I'm aware of.

We plan to address this in next-gen however.

Thank you for your answer, look forward to

@cxdtotsj
Copy link
Author

Thank you. When is the next version expected to be released?

@RonnyPfannschmidt
Copy link
Member

I'd like to note that mutation of nodeid is absolutely unsupported and any breakage is on the person doing it,

It's not a use case that should be supported

@BeyondEvil
Copy link
Contributor

Thank you. When is the next version expected to be released?

Any day now 😅

@wu-clan
Copy link

wu-clan commented Apr 27, 2023

Tested hooks on 4.0.0rc4, terminal and html file are no longer garbled

def pytest_collection_modifyitems(items):
    for item in items:
        item.name = item.name.encode("utf-8").decode("unicode_escape")
        item._nodeid = item.nodeid.encode("utf-8").decode("unicode_escape")

When will 4.0.0 be released?

@BeyondEvil
Copy link
Contributor

I’m releasing rc5 before EOW for a final round of testing.

Then as soon as I’ve updated docs incl. Changelog, I’ll release 4.0.0.

@cxdtotsj
Copy link
Author

cxdtotsj commented Jun 8, 2023

Well done, looking forward to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants