Skip to main content

pytest plugin for generating HTML reports

Project description

pytest-html is a plugin for py.test that generates a HTML report for the test results.

License PyPI Travis Issues Requirements

Requirements

You will need the following prerequisites in order to use pytest-html:

  • Python 2.6, 2.7, 3.2, 3.3, 3.4, PyPy, or PyPy3

  • py.test 2.6 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

def pytest_runtest_makereport(__multicall__, item):
    pytest_html = item.config.pluginmanager.getplugin('html')
    report = __multicall__.execute()
    extra = getattr(report, 'extra', [])
    if report.when == 'call':
        # always add url to report
        extra.append(pytest_html.extras.url('http://www.example.com/'))
        xfail = hasattr(report, 'wasxfail')
        if (report.skipped and xfail) or (report.failed and not xfail):
            # only add additional html on failure
            extra.append(pytest_html.extras.html(html.div('Additional HTML')))
        report.extra = extra
    return report

Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-html-1.4.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_html-1.4-py2.py3-none-any.whl (11.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-html-1.4.tar.gz.

File metadata

  • Download URL: pytest-html-1.4.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytest-html-1.4.tar.gz
Algorithm Hash digest
SHA256 0b573c778d3a6094fd82fdc136f36c97462a978793509efb5e4ddb408333fa81
MD5 38646ec673bca3b8cd276cb4bdda5cb8
BLAKE2b-256 b61decd0cdb38ac88794330c1ddb4751efb4921c3822d5e086bb018fb90dbb5e

See more details on using hashes here.

File details

Details for the file pytest_html-1.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_html-1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 deb0b9f0efdfd27dd871f2216ad6419f9555210a3d6263844978ee87eb0adbd0
MD5 0643be13fe9aee1234f926c4f364ce39
BLAKE2b-256 5b88abb2cb7b04385d5121fe24f4c3d61fd0d41553d964a281a26c9133d4988b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page