HTML extras for 'call' and 'teardown' phases get merged

Ouverte
#1,077 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

@contputer0x0 y travaille déjà.

Depuis le 11/10/2026.

  • #1078 par @contputer0x0 — ouverte

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
68/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
python
Domaine
testing-qa

Piste de recherche

Reproduce the regression with the provided conftest.py and bug_test.py files, using the pytest-html report output as the starting point. Compare how extras are collected for the call and teardown phases, then verify that each report displays only its own phase's HTML extra and that the regression is covered by a test.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

The extras added during the call and teardown phases get merged and are displayed in both call and teardown HTML reports

Use this conftest.py file:

import pytest


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield

    pytest_html = item.config.pluginmanager.getplugin("html")
    report = outcome.get_result()
    extras = getattr(report, "extras", [])

    if (
        report.when in ("setup", "teardown") and
        report.outcome in ('failed', 'skipped')
    ):
        extras.append(pytest_html.extras.html(f'<p>We are in {report.when} phase</p>'))

    if report.when == "call":
        extras.append(pytest_html.extras.html(f'<p>We are in {report.when} phase</p>'))

    report.extras = extras

Use this bug_test.py file:

import pytest


@pytest.fixture
def teardown():
    yield
    assert False


def test_extras(teardown):
    pass

Run the test

Actual result:

The extras for call and teardown are merged and are displayed in both call and teardown reports

Image

Expected result:

  • The call report only displays the extras added during the call phase (<p>We are in call phase</p>)
  • The teardown report only displays the extras added during the teardown phase (<p>We are in teardown phase</p>)

This is a regression. We didn't have this bug in pytest-html==4.1.0

Langage dominant
Python
Étoiles
779
Forks
261
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de pytest-dev/pytest-html

Toutes les issues de pytest-dev/pytest-html

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.