===============
pytest-reporter
===============
.. image:: https://img.shields.io/pypi/v/pytest-reporter.svg
:target: https://pypi.org/project/pytest-reporter
:alt: PyPI version
Generate `Pytest`_ reports from templates. You may use one of the available
templates on PyPI (like the reference template `pytest-reporter-html1`_),
inherit them in your own template to tweak their content and appearence or
make your own from scratch.
Anything text based can be generated like HTML, LaTeX, CSV et.c.
Installation
------------
You can install "pytest-reporter" via `pip`_ from `PyPI`_::
$ pip install pytest-reporter
Usage
-----
Specify the template you want to use and the output path of the report::
$ pytest --template-dir=templates --template=report.html --report=report.html
Writing templates
-----------------
This plugin does not come with built-in support for any template engines,
it is up to each template to implement the rendering (or use another template
plugin as base). A minimal template may just implement the
``pytest_reporter_render`` hook.
This is a very basic Jinja2 template implementation:
.. code:: python
from jinja2 import Environment, FileSystemLoader, TemplateNotFound
def pytest_reporter_render(template_name, dirs, context):
env = Environment(loader=FileSystemLoader(dirs))
try:
template = env.get_template(template_name)
except TemplateNotFound:
# Don't know about this name, may be provided by some other template
return
return template.render(context)
See `pytest-reporter-html1`_ for a full reference implementation.
The template context
--------------------
The standard context available for all templates include the following:
* ``config``: `Config <https://docs.pytest.org/en/latest/reference.html#config>`_
* ``session``: `Session <https://docs.pytest.org/en/latest/reference.html#session>`_
* ``started``: Unix timestamp when session started
* ``ended``: Unix timestamp when session was finished
* ``warnings[]``: List of warnings.WarningMessage
* ``items``: Dictionary of collected items with nodeid as keys
* ``tests[]``: List of each test run as dictionaries with the following keys:
* ``item``: `Item <https://docs.pytest.org/en/latest/reference.html#item>`_
* ``phases[]``: List of each test phase (setup, call, teardown) as dictionaries
with the following keys:
* ``call`` (optional): `CallInfo <https://docs.pytest.org/en/latest/reference.html#callinfo>`_ if available.
* ``report``: `TestReport <https://docs.pytest.org/en/latest/reference.html#testreport>`_
* ``sections``: Same as ``report.sections`` but only the sections captured for this phase
* ``log_records[]``: List of `logging.LogRecord <https://docs.python.org/3/library/logging.html#logging.LogRecord>`_
recorded during the test phase
* ``status``: Status of this phase. Dictionary with the following keys:
* ``category``: Category of the status (e.g. ``"passed"``) or empty string
* ``letter``: Single letter version of status (e.g. ``"P"``) or empty string
* ``word``: Uppercase word version of status (e.g. ``"PASSED"``) or empty string
* ``style``: Dictionary with e.g. ``{"yellow": True}`` or empty dictionary
* ``status``: Status of whole test. Dictionary with the following keys:
* ``category``: Category of the test status (e.g. ``"passed"``)
* ``letter``: Single letter version of test status (e.g. ``"P"``)
* ``word``: Uppercase word version of test status (e.g. ``"PASSED"``)
* ``style``: Dictionary with e.g. ``{"yellow": True}`` or empty dictionary
The context may be extended or modified using the following methods:
* ``config.template_context``
* The ``template_context`` fixture
* The ``pytest_reporter_context()`` hook
Hooks
-----
See `hooks.py`_ for a complete list of hooks available.
License
-------
Distributed under the terms of the `MIT`_ license, "pytest-reporter" is free and open source software
Issues
------
If you encounter any problems, please `file an issue`_ along with a detailed description.
.. _`pytest-reporter-html1`: https://pypi.org/project/pytest-reporter-html1
.. _`MIT`: http://opensource.org/licenses/MIT
.. _`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
.. _`hooks.py`: https://github.com/christiansandberg/pytest-reporter/blob/master/pytest_reporter/hooks.py
Raw data
{
"_id": null,
"home_page": "https://github.com/christiansandberg/pytest-reporter",
"name": "pytest-reporter",
"maintainer": "Christian Sandberg",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "christiansandberg@me.com",
"keywords": "",
"author": "Christian Sandberg",
"author_email": "christiansandberg@me.com",
"download_url": "https://files.pythonhosted.org/packages/0a/1a/a5f46dd3b78dc207de5813342b3e51207d1bcae92207443536d0f6df24e2/pytest-reporter-0.5.3.tar.gz",
"platform": null,
"description": "===============\r\npytest-reporter\r\n===============\r\n\r\n.. image:: https://img.shields.io/pypi/v/pytest-reporter.svg\r\n :target: https://pypi.org/project/pytest-reporter\r\n :alt: PyPI version\r\n\r\nGenerate `Pytest`_ reports from templates. You may use one of the available\r\ntemplates on PyPI (like the reference template `pytest-reporter-html1`_),\r\ninherit them in your own template to tweak their content and appearence or\r\nmake your own from scratch.\r\n\r\nAnything text based can be generated like HTML, LaTeX, CSV et.c.\r\n\r\n\r\nInstallation\r\n------------\r\n\r\nYou can install \"pytest-reporter\" via `pip`_ from `PyPI`_::\r\n\r\n $ pip install pytest-reporter\r\n\r\n\r\nUsage\r\n-----\r\n\r\nSpecify the template you want to use and the output path of the report::\r\n\r\n $ pytest --template-dir=templates --template=report.html --report=report.html\r\n\r\n\r\nWriting templates\r\n-----------------\r\n\r\nThis plugin does not come with built-in support for any template engines,\r\nit is up to each template to implement the rendering (or use another template\r\nplugin as base). A minimal template may just implement the\r\n``pytest_reporter_render`` hook.\r\n\r\nThis is a very basic Jinja2 template implementation:\r\n\r\n.. code:: python\r\n\r\n from jinja2 import Environment, FileSystemLoader, TemplateNotFound\r\n\r\n def pytest_reporter_render(template_name, dirs, context):\r\n env = Environment(loader=FileSystemLoader(dirs))\r\n try:\r\n template = env.get_template(template_name)\r\n except TemplateNotFound:\r\n # Don't know about this name, may be provided by some other template\r\n return\r\n return template.render(context)\r\n\r\nSee `pytest-reporter-html1`_ for a full reference implementation.\r\n\r\n\r\nThe template context\r\n--------------------\r\n\r\nThe standard context available for all templates include the following:\r\n\r\n* ``config``: `Config <https://docs.pytest.org/en/latest/reference.html#config>`_\r\n* ``session``: `Session <https://docs.pytest.org/en/latest/reference.html#session>`_\r\n* ``started``: Unix timestamp when session started\r\n* ``ended``: Unix timestamp when session was finished\r\n* ``warnings[]``: List of warnings.WarningMessage\r\n* ``items``: Dictionary of collected items with nodeid as keys\r\n* ``tests[]``: List of each test run as dictionaries with the following keys:\r\n\r\n * ``item``: `Item <https://docs.pytest.org/en/latest/reference.html#item>`_\r\n * ``phases[]``: List of each test phase (setup, call, teardown) as dictionaries\r\n with the following keys:\r\n\r\n * ``call`` (optional): `CallInfo <https://docs.pytest.org/en/latest/reference.html#callinfo>`_ if available.\r\n * ``report``: `TestReport <https://docs.pytest.org/en/latest/reference.html#testreport>`_\r\n * ``sections``: Same as ``report.sections`` but only the sections captured for this phase\r\n * ``log_records[]``: List of `logging.LogRecord <https://docs.python.org/3/library/logging.html#logging.LogRecord>`_\r\n recorded during the test phase\r\n * ``status``: Status of this phase. Dictionary with the following keys:\r\n\r\n * ``category``: Category of the status (e.g. ``\"passed\"``) or empty string\r\n * ``letter``: Single letter version of status (e.g. ``\"P\"``) or empty string\r\n * ``word``: Uppercase word version of status (e.g. ``\"PASSED\"``) or empty string\r\n * ``style``: Dictionary with e.g. ``{\"yellow\": True}`` or empty dictionary\r\n\r\n * ``status``: Status of whole test. Dictionary with the following keys:\r\n\r\n * ``category``: Category of the test status (e.g. ``\"passed\"``)\r\n * ``letter``: Single letter version of test status (e.g. ``\"P\"``)\r\n * ``word``: Uppercase word version of test status (e.g. ``\"PASSED\"``)\r\n * ``style``: Dictionary with e.g. ``{\"yellow\": True}`` or empty dictionary\r\n\r\nThe context may be extended or modified using the following methods:\r\n\r\n* ``config.template_context``\r\n* The ``template_context`` fixture\r\n* The ``pytest_reporter_context()`` hook\r\n\r\n\r\nHooks\r\n-----\r\n\r\nSee `hooks.py`_ for a complete list of hooks available.\r\n\r\n\r\nLicense\r\n-------\r\n\r\nDistributed under the terms of the `MIT`_ license, \"pytest-reporter\" is free and open source software\r\n\r\n\r\nIssues\r\n------\r\n\r\nIf you encounter any problems, please `file an issue`_ along with a detailed description.\r\n\r\n.. _`pytest-reporter-html1`: https://pypi.org/project/pytest-reporter-html1\r\n.. _`MIT`: http://opensource.org/licenses/MIT\r\n.. _`file an issue`: https://github.com/christiansandberg/pytest-reporter/issues\r\n.. _`pytest`: https://github.com/pytest-dev/pytest\r\n.. _`pip`: https://pypi.org/project/pip/\r\n.. _`PyPI`: https://pypi.org/project\r\n.. _`hooks.py`: https://github.com/christiansandberg/pytest-reporter/blob/master/pytest_reporter/hooks.py\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Generate Pytest reports with templates",
"version": "0.5.3",
"project_urls": {
"Homepage": "https://github.com/christiansandberg/pytest-reporter"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e3762bac8243221186d8e8825912b95b04b3110c14f2cb4da6fbc476736e81e5",
"md5": "98961585ca61432b5f8d935290c1d4e0",
"sha256": "fa39fef46b1926b6f181c2759da0bcfd26b7697ef59d3c5cd260106c59b3a196"
},
"downloads": -1,
"filename": "pytest_reporter-0.5.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "98961585ca61432b5f8d935290c1d4e0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7580,
"upload_time": "2024-02-28T19:20:39",
"upload_time_iso_8601": "2024-02-28T19:20:39.242345Z",
"url": "https://files.pythonhosted.org/packages/e3/76/2bac8243221186d8e8825912b95b04b3110c14f2cb4da6fbc476736e81e5/pytest_reporter-0.5.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0a1aa5f46dd3b78dc207de5813342b3e51207d1bcae92207443536d0f6df24e2",
"md5": "48660eab057e7394c03ac7a827d0ab2f",
"sha256": "426ae38f3c5304659635eff1d4080c8acf4dc6cd833469caed427a9a80bb41aa"
},
"downloads": -1,
"filename": "pytest-reporter-0.5.3.tar.gz",
"has_sig": false,
"md5_digest": "48660eab057e7394c03ac7a827d0ab2f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9815,
"upload_time": "2024-02-28T19:20:41",
"upload_time_iso_8601": "2024-02-28T19:20:41.039061Z",
"url": "https://files.pythonhosted.org/packages/0a/1a/a5f46dd3b78dc207de5813342b3e51207d1bcae92207443536d0f6df24e2/pytest-reporter-0.5.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-28 19:20:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "christiansandberg",
"github_project": "pytest-reporter",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pytest-reporter"
}