You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing data in HTML report table after upgrading to pytest-html 4.1.1 #849
Hi Team,
I'm currently encountering a problem with pytest-html after upgrading from version 3.2.0 to 4.1.1. My HTML reports are now empty when running tagged tests, although untagged tests generate reports correctly.
I'm suspecting since pytest_html_results_table_header hook is not invoking in pytest-html 4.1.1 when running tests with tags. With pytest_html_results_table_header hook I’m trying to insert a snapshot column for failed test , since the table is not properly customized I'm getting an empty report. This hook was invoked in the previous version and is still invoking in 4.1.1 when running tests without tags. The lack of this hook prevents proper table customization, resulting in an empty table.
Observed Behavior: The HTML report's results table is empty when running the tests with tags.
Expected Behavior: The results table should display all test results (name, outcome, duration), including the newer column 'snapshot' when running the tests with tags.
python run.py —tags=html_report - with tags -issues with latest version4.1.1, But when i downgraded to 3.2.0 got html table table with data as expected.
python run.py tests/test_pytest_html.py - without tags -no issues with both the versions
**Got INTERNALERROR : **
`INTERNALERROR> File ".nox/tests/lib/python3.10/site-packages/pytest_html/basereport.py", line 245, in pytest_runtest_logreport
INTERNALERROR> self._process_report(each, dur)
INTERNALERROR> File ".nox/tests/lib/python3.10/site-packages/pytest_html/basereport.py", line 283, in _process_report
INTERNALERROR> self._hydrate_data(data, cells)
INTERNALERROR> File ".nox/tests/lib/python3.10/site-packages/pytest_html/basereport.py", line 159, in _hydrate_data
INTERNALERROR> if "sortable" in self._report.table_header[index]:
INTERNALERROR> IndexError: list index out of range`
I'm suspecting the way to invoking this pytest_html_results_table_header while run the tests with tags is changed in the latest version
def pytest_addoption(parser):
parser.addoption("--tags", nargs="+", metavar="TAG", help="Tags to filter tests")
def pytest_configure(config):
# configured using config.getoption("--tags")
def pytest_collection_modifyitems(items, config):
tags = config.option.tags
if tags:
selected_items = [item for item in items if any(tag in item.keywords for tag in tags)]
items[:] = selected_items
I'm suspecting this issue is with the pytest_html_results_table_header hook after upgrading to pytest-html 4.1.1. In version 3.2.0, this hook was called during pytest_sessionfinish, but it now appears to be called during pytest_sessionstart in the latest version. But the pytest_sessionstart itself is not invoked.
Could you please suggest how to invoke pytest_sessionstart from my current setup, and also let me know if I can customize the HTML report header in any other way?
I am also facing the same issue as pytest_html_results_table_header and pytest_html_report_title fixtures get called first instead of at the end of the session while generating report.
The last stable version where the test report got generated successfully is pytest-html==3.2.0.
I encountered the same issue - it appears that the file or folder name affects how the HTML file is rendered in the browser. If the file path contains special characters, such as “ä”, it seems to break the HTML file.
(Observed with pytest-html versions 4.1.1 and 4.2.0.)
Activity
BeyondEvil commentedon Nov 22, 2024
Could you create a small reproducible example?
Also, please dump any output in the browser console here.
Thanks 🙏🏼
Ramya2801 commentedon Nov 22, 2024
Example unit test:
conftest.py
Run command :
python run.py —tags=html_report - with tags -issues with latest version4.1.1, But when i downgraded to 3.2.0 got html table table with data as expected.
python run.py tests/test_pytest_html.py - without tags -no issues with both the versions
**Got INTERNALERROR : **
`INTERNALERROR> File ".nox/tests/lib/python3.10/site-packages/pytest_html/basereport.py", line 245, in pytest_runtest_logreport
INTERNALERROR> self._process_report(each, dur)
INTERNALERROR> File ".nox/tests/lib/python3.10/site-packages/pytest_html/basereport.py", line 283, in _process_report
INTERNALERROR> self._hydrate_data(data, cells)
INTERNALERROR> File ".nox/tests/lib/python3.10/site-packages/pytest_html/basereport.py", line 159, in _hydrate_data
INTERNALERROR> if "sortable" in self._report.table_header[index]:
INTERNALERROR> IndexError: list index out of range`
I'm suspecting the way to invoking this pytest_html_results_table_header while run the tests with tags is changed in the latest version
BeyondEvil commentedon Nov 22, 2024
What is
run.py?What happens if you run it with
pytest?Where does the
--tagsflag come from?Ramya2801 commentedon Nov 25, 2024
pytestI am experiencing the same behavior when I run with pytest as well...
Pytest command :
pytest --color=yes --tags=pytest_html--tagsthese tags were configured in another file
I'm suspecting this issue is with the pytest_html_results_table_header hook after upgrading to pytest-html 4.1.1. In version 3.2.0, this hook was called during pytest_sessionfinish, but it now appears to be called during pytest_sessionstart in the latest version. But the pytest_sessionstart itself is not invoked.
Could you please suggest how to invoke pytest_sessionstart from my current setup, and also let me know if I can customize the HTML report header in any other way?
shrutinipane commentedon Nov 26, 2024
I am also facing the same issue as pytest_html_results_table_header and pytest_html_report_title fixtures get called first instead of at the end of the session while generating report.
The last stable version where the test report got generated successfully is pytest-html==3.2.0.
a-kleinf commentedon Feb 26, 2026
I encountered the same issue - it appears that the file or folder name affects how the HTML file is rendered in the browser. If the file path contains special characters, such as “ä”, it seems to break the HTML file.
(Observed with pytest-html versions 4.1.1 and 4.2.0.)