pytest-html
pytest-html is a plugin for py.test that generates a HTML report for the test results.
Requirements
You will need the following prerequisites in order to use pytest-html:
Python 2.6, 2.7, 3.2, 3.3, 3.4 or PyPy
py.test 2.3 or newer
Installation
To install pytest-html:
pip install pytest-html
Then run your tests with:
py.test --html=report.html
Enhancing reports
You can add an Environment section to the report by implementing the
pytest_html_environment hook and returning a dict representing the test
environment. For example:
def pytest_html_environment(config):
return {'foo': 'bar'}
You can add details to the HTML reports by creating an ‘extra’ list on the
report object. The following example adds the various types of extras using a
pytest_runtest_makereport hook, which can be implemented in a plugin or
conftest.py file:
from py.xml import html
from html import extras
def pytest_runtest_makereport(__multicall__, item):
report = __multicall__.execute()
extra = getattr(report, 'extra', [])
if report.when == 'call':
xfail = hasattr(report, 'wasxfail')
if (report.skipped and xfail) or (report.failed and not xfail):
url = TestSetup.selenium.current_url
report.extra.append(extras.url(url))
screenshot = TestSetup.selenium.get_screenshot_as_base64()
report.extra.append(extras.image(screenshot, 'Screenshot'))
html = TestSetup.selenium.page_source.encode('utf-8')
report.extra.append(extra.text(html, 'HTML'))
report.extra.append(extra.html(html.div('Additional HTML')))
report.extra = extra
return report
Resources
Metadata
Release files for pytest-html 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest-html-1.2.tar.gz | 7.4 kB | Without provenance | Details for pytest-html-1.2.tar.gz |
Release files / pytest-html-1.2.tar.gz
| Download URL | pytest-html-1.2.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44f0904a07b57415e46cdd9dec7778076be13e7c776692f1c7c9084fe38aa38c
|
|
BLAKE2b-256 checksum How to use checksums |
3f40260c353d283a7a5bcc3c2c1c7c541d7eaefc71e9dc6d6cfd1b03c1bb76f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pytest-html 1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.