Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#1,077 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
testing-qa

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.0.0

Lingua principale
Python
Stelle
779
Fork
259
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytest-dev/pytest-html

Tutte le issue di pytest-dev/pytest-html

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.