Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#1,077 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
testing-qa

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Python
Estrellas
779
Forks
259
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pytest-dev/pytest-html

Todos los issues de pytest-dev/pytest-html

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.