pytest-dev / pytest-dev/pytest-html
4.1.0 - report not generating data
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 779
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
``When using pytest-html 3.2.0, the report generated correctly, showing details of failed tests.
When upgraded to pytest-html-4.1.0, the report no longer showed this data.
By upgrading and downgrading I can make the report work correctly and break it again. The only thing effecting the report generating is the version of pytest-html.
Below is my function for the report:
`@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item):
"""
Extends the PyTest Plugin to take and embed screenshot in html report, whenever test fails.
:param item:
"""
pytest_html = item.config.pluginmanager.getplugin('html')
outcome = yield
report = outcome.get_result()
extra = getattr(report, 'extra', [])
# Add rerun information if available
rerun = item.config.option.reruns
if rerun:
if hasattr(report, "rerun") and report.rerun > 0:
extra.append(pytest_html.extras.text(f"Rerun Attempt: {report.rerun}", mime_type="text/plain"))
# Embed screenshots for failed or rerun tests
if report.when == 'call' or report.when == "setup":
xfail = hasattr(report, 'wasxfail')
if (report.skipped and xfail) or (report.failed and not xfail):
base64_image = _capture_screenshot()
if base64_image:
html = (
f'<div>'
f'<img src="data:image/png;base64,{base64_image}" alt="screenshot"'
f' style="width:304px;height:228px;" onclick="window.open(this.src)" align="right"/>'
f'</div>'
)
extra.append(pytest_html.extras.html(html))
# Assign updated extras back to the report
report.extra = extra
def _capture_screenshot():
return driver.get_screenshot_as_base64()`
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported pytest_runtest_makereport hook and compare its behavior with pytest-html 3.2.0 and 4.1.0. Reproduce the report-generation difference using the supplied screenshot and rerun-extra logic; done means failed-test details and embedded extras appear in the generated report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100