
Security News
Python Adopts Standard Lock File Format for Reproducible Installs
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
.. 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.
You can install "pytest-reporter" via pip
_ from PyPI
_::
$ pip install pytest-reporter
Specify the template you want to use and the output path of the report::
$ pytest --template-dir=templates --template=report.html --report=report.html
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 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 stringletter
: Single letter version of status (e.g. "P"
) or empty stringword
: Uppercase word version of status (e.g. "PASSED"
) or empty stringstyle
: Dictionary with e.g. {"yellow": True}
or empty dictionarystatus
: 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 dictionaryThe context may be extended or modified using the following methods:
config.template_context
template_context
fixturepytest_reporter_context()
hookSee hooks.py
_ for a complete list of hooks available.
Distributed under the terms of the MIT
_ license, "pytest-reporter" is free and open source software
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
FAQs
Generate Pytest reports with templates
We found that pytest-reporter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
Security News
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.