pytest-html icon indicating copy to clipboard operation
pytest-html copied to clipboard

pytest terminal transcoding unicode conflict with report

Open cxdtotsj opened this issue 4 years ago • 9 comments

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.

cxdtotsj avatar Apr 12 '21 08:04 cxdtotsj

Is there a good solution to this problem at present?

wu-clan avatar Apr 27 '22 18:04 wu-clan

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

We plan to address this in next-gen however.

BeyondEvil avatar Apr 27 '22 20:04 BeyondEvil

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

wu-clan avatar Apr 28 '22 11:04 wu-clan

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

cxdtotsj avatar Aug 22 '22 07:08 cxdtotsj

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

RonnyPfannschmidt avatar Aug 22 '22 07:08 RonnyPfannschmidt

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

Any day now 😅

BeyondEvil avatar Sep 09 '22 21:09 BeyondEvil

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?

wu-clan avatar Apr 27 '23 05:04 wu-clan

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.

BeyondEvil avatar Apr 27 '23 05:04 BeyondEvil

Well done, looking forward to it.

cxdtotsj avatar Jun 08 '23 01:06 cxdtotsj