pytest terminal transcoding unicode conflict with report
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,

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.
Is there a good solution to this problem at present?
Unfortunately not. At least not one that I'm aware of.
We plan to address this in next-gen however.
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
Thank you. When is the next version expected to be released?
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
Thank you. When is the next version expected to be released?
Any day now 😅
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?
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.
Well done, looking forward to it.