pytest-dev / pytest-dev/pytest-html
pytest terminal transcoding unicode conflict with report
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 779
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the reported pytest command, the conftest.py pytest_collection_modifyitems hook, and a parametrized Unicode test. Compare how pytest-html 2.0.0 and 3.x use report.nodeid in TestResult; done means the generated HTML report preserves the readable test title when the hook is enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100