pytest-html does not escape HTML in testId (v4.2.0)

Open
#1,024 0 comments 0 reactions 0 assignees View on GitHub

@golikovichev is already working on this.

Since Jun 9, 2026.

  • #1036 by @golikovichev — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
html, python
Domain
testing-qa

Research direction

Start by running the supplied parametrized Python test and inspecting the generated pytest-html report. The issue names no repository file or test to begin with, so trace how the testId is inserted into the report. Done means the report consistently renders the testId as literal text rather than interpreting its HTML markup.

Written by the indexing model from the issue text.

Description

Hello,

I created a parametrize test where testId contains the following text:

<span style="font-weight: bold; color: red; font-size: 2em;">text</span>

pytest-html generated the next report:

Image

Is it an expected behaviour?

Test code:

import pytest        
@pytest.mark.parametrize(
    "data",
    [
        '<span style="font-weight: bold; color: red; font-size: 2em;">text</span>',
    ],
)
def test_unescape(data): print("ha-ha")
Dominant language
Python
Stars
779
Forks
261
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pytest-dev/pytest-html

All issues in pytest-dev/pytest-html

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.