A basic HTML report template for Pytest
Project description
=====================
pytest-reporter-html1
=====================
.. image:: https://img.shields.io/pypi/v/pytest-reporter-html1.svg
:target: https://pypi.org/project/pytest-reporter-html1
:alt: PyPI version
A basic HTML report for Pytest using `Jinja2`_ template engine.
Features
--------
* Expand and retract sections as needed
* Tests organized by files
* Complies with Jenkins default CSP policy (with ``--split-report``)
* reStructuredText support in test function documentation
* Minified content
* May be used as a base template for customization
.. image:: https://raw.githubusercontent.com/christiansandberg/pytest-reporter-html1/develop/screenshot.png
:alt: Screenshot
:scale: 50 %
Installation
------------
You can install "pytest-reporter-html1" via `pip`_ from `PyPI`_::
$ pip install pytest-reporter-html1
Usage
-----
Specify the html1 template and the output path of the report::
$ pytest --template=html1/index.html --report=report.html
By default the report is self-contained, but you can separate CSS, images,
and JavaScript by specifying the ``--split-report`` option.
Customization
-------------
You can inherit this template in your own to tailor parts of it to your own needs.
It defines various blocks which you can override using `template inheritance`_.
.. code:: html
{% extends "html1/index.html" %}
{% block style %}
{{ super() }}
header {
background-color: black;
}
body {
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
}
{% endblock %}
Some additional filters are available for templates to use:
``asset(path)``
Takes a path to a local file and either returns a base64 encoded URL or a
new relative URL to a copy depending on if the report is self-contained or not.
.. code:: html
<img src="{{ 'temporary_path/image.png'|asset }}">
``ansi(s)``
Convert ANSI color codes to HTML.
``strftime(value, format)``
Format a Unix timestamp using `datetime.strftime`_.
.. code:: html
Started: {{ started|strftime('%Y-%m-%d %H:%M:%S') }}
``timedelta(value)``
Convert a time in seconds to a `timedelta`_ object.
``cleandoc(s)``
Clean docstring using `inspect.cleandoc`_.
``rst(s)``
Convert reStructuredText to HTML.
Issues
------
If you encounter any problems, please `file an issue`_ along with a detailed description.
.. _`Jinja2`: https://jinja.palletsprojects.com/
.. _`template inheritance`: https://jinja.palletsprojects.com/en/master/templates/#template-inheritance
.. _`file an issue`: https://github.com/christiansandberg/pytest-reporter/issues
.. _`pytest`: https://github.com/pytest-dev/pytest
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project
.. _`datetime.strftime`: https://docs.python.org/3/library/datetime.html#datetime.datetime.strftime
.. _`timedelta`: https://docs.python.org/3/library/datetime.html#timedelta-objects
.. _`inspect.cleandoc`: https://docs.python.org/3/library/inspect.html#inspect.cleandoc
pytest-reporter-html1
=====================
.. image:: https://img.shields.io/pypi/v/pytest-reporter-html1.svg
:target: https://pypi.org/project/pytest-reporter-html1
:alt: PyPI version
A basic HTML report for Pytest using `Jinja2`_ template engine.
Features
--------
* Expand and retract sections as needed
* Tests organized by files
* Complies with Jenkins default CSP policy (with ``--split-report``)
* reStructuredText support in test function documentation
* Minified content
* May be used as a base template for customization
.. image:: https://raw.githubusercontent.com/christiansandberg/pytest-reporter-html1/develop/screenshot.png
:alt: Screenshot
:scale: 50 %
Installation
------------
You can install "pytest-reporter-html1" via `pip`_ from `PyPI`_::
$ pip install pytest-reporter-html1
Usage
-----
Specify the html1 template and the output path of the report::
$ pytest --template=html1/index.html --report=report.html
By default the report is self-contained, but you can separate CSS, images,
and JavaScript by specifying the ``--split-report`` option.
Customization
-------------
You can inherit this template in your own to tailor parts of it to your own needs.
It defines various blocks which you can override using `template inheritance`_.
.. code:: html
{% extends "html1/index.html" %}
{% block style %}
{{ super() }}
header {
background-color: black;
}
body {
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
}
{% endblock %}
Some additional filters are available for templates to use:
``asset(path)``
Takes a path to a local file and either returns a base64 encoded URL or a
new relative URL to a copy depending on if the report is self-contained or not.
.. code:: html
<img src="{{ 'temporary_path/image.png'|asset }}">
``ansi(s)``
Convert ANSI color codes to HTML.
``strftime(value, format)``
Format a Unix timestamp using `datetime.strftime`_.
.. code:: html
Started: {{ started|strftime('%Y-%m-%d %H:%M:%S') }}
``timedelta(value)``
Convert a time in seconds to a `timedelta`_ object.
``cleandoc(s)``
Clean docstring using `inspect.cleandoc`_.
``rst(s)``
Convert reStructuredText to HTML.
Issues
------
If you encounter any problems, please `file an issue`_ along with a detailed description.
.. _`Jinja2`: https://jinja.palletsprojects.com/
.. _`template inheritance`: https://jinja.palletsprojects.com/en/master/templates/#template-inheritance
.. _`file an issue`: https://github.com/christiansandberg/pytest-reporter/issues
.. _`pytest`: https://github.com/pytest-dev/pytest
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project
.. _`datetime.strftime`: https://docs.python.org/3/library/datetime.html#datetime.datetime.strftime
.. _`timedelta`: https://docs.python.org/3/library/datetime.html#timedelta-objects
.. _`inspect.cleandoc`: https://docs.python.org/3/library/inspect.html#inspect.cleandoc
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest-reporter-html1-0.3.1.tar.gz.
File metadata
- Download URL: pytest-reporter-html1-0.3.1.tar.gz
- Upload date:
- Size: 85.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39650e9152a66a1b9730aa61462d2e9bd8ccb986c25881a9aa3e4f2a43631573
|
|
| MD5 |
c73d6d5327e8b85ab6c5c7ca5772e14d
|
|
| BLAKE2b-256 |
e6a7dd36aff797ec85940e66d8377ea270af061dcacf1f7cc8df64d004e55afe
|
File details
Details for the file pytest_reporter_html1-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pytest_reporter_html1-0.3.1-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ffdccdc0cb3ced3dcd5f623b899c92a3b8ff52f4bb3eea2e2004bd2fdeaea49
|
|
| MD5 |
8f504626054885f28a37c7bfd6f514e6
|
|
| BLAKE2b-256 |
0a9fa567f416288047290c67465086d3a640a5f3793ead2249fdcb6eaf9f5dc0
|