Skip to main content

A pytest plugin to make a test results report with Markdown table format.

Project description

.. contents:: **pytest-md-report**
:backlinks: top
:depth: 2


Summary
============================================
.. image:: https://badge.fury.io/py/pytest-md-report.svg
:target: https://badge.fury.io/py/pytest-md-report
:alt: PyPI package version

.. image:: https://img.shields.io/pypi/pyversions/pytest-md-report.svg
:target: https://pypi.org/project/pytest-md-report
:alt: Supported Python versions

.. image:: https://img.shields.io/pypi/implementation/pytest-md-report.svg
:target: https://pypi.org/project/pytest-md-report
:alt: Supported Python implementations

.. image:: https://github.com/thombashi/pytest-md-report/workflows/Tests/badge.svg
:target: https://github.com/thombashi/pytest-md-report/actions?query=workflow%3ATests
:alt: Linux/macOS/Windows CI status

.. image:: https://github.com/thombashi/pytest-md-report/actions/workflows/github-code-scanning/codeql/badge.svg
:target: https://github.com/thombashi/pytest-md-report/actions/workflows/github-code-scanning/codeql
:alt: CodeQL

A pytest plugin to make test results report with Markdown table format.


Installation
============================================
::

pip install pytest-md-report


Usage
============================================
::

pytest --md-report examples/

.. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytest-md-report@master/ss/pytest_md_report_example.png
:scale: 80%
:alt: https://github.com/thombashi/pytest-md-report/blob/master/ss/pytest_md_report_example.png

Output example


Other examples
--------------------------------------------
Increase verbosity level (``--md-report-verbose`` option):

::

pytest --md-report --md-report-verbose=1 examples/

.. figure:: https://cdn.jsdelivr.net/gh/thombashi/pytest-md-report@master/ss/pytest_md_report_example_verbose.png
:scale: 80%
:alt: https://github.com/thombashi/pytest-md-report/blob/master/ss/pytest_md_report_example_verbose.png

Output example (verbose)

Not rendering results of zero value (``--md-report-zeros emmpty`` option):

::

pytest --md-report --md-report-zeros empty --md-report-color never examples/

::

| filepath | passed | failed | error | skipped | xfailed | xpassed | SUBTOTAL |
| ------------------------ | -----: | -----: | ----: | ------: | ------: | ------: | -------: |
| examples/test_error.py | | | 2 | | | | 2 |
| examples/test_failed.py | | 2 | | | | | 2 |
| examples/test_pass.py | 2 | | | | | | 2 |
| examples/test_skipped.py | | | | 2 | | | 2 |
| examples/test_xfailed.py | | | | | 2 | | 2 |
| examples/test_xpassed.py | | | | | | 2 | 2 |
| TOTAL | 2 | 2 | 2 | 2 | 2 | 2 | 12 |


Config file examples
--------------------------------------------
You can set configurations with ``pyproject.toml`` or ``setup.cfg`` as follows.

:Example of ``pyproject.toml``:
.. code-block:: toml

[tool.pytest.ini_options]
md_report = true
md_report_verbose = 0
md_report_color = "auto"

:Example of ``setup.cfg``:
.. code-block:: ini

[tool:pytest]
md_report = True
md_report_verbose = 0
md_report_color = auto

Options
============================================

Command options
--------------------------------------------
::

make test results report with markdown table format:
--md-report Create Markdown report. you can also specify the value with PYTEST_MD_REPORT environment variable.
--md-report-verbose=VERBOSITY_LEVEL
Verbosity level for pytest-md-report.
If not set, use the verbosity level of pytest.
Defaults to 0.
you can also specify the value with PYTEST_MD_REPORT_VERBOSE environment variable.
--md-report-output=FILEPATH
Path to a file to the outputs test report.
Overwrite a file content if the file already exists.
you can also specify the value with PYTEST_MD_REPORT_OUTPUT environment variable.
--md-report-tee output test report for both standard output and a file. you can also specify the value with PYTEST_MD_REPORT_TEE environment variable.
--md-report-color={auto,text,never}
How to color output reports.
auto: render colored (text and background) reports using ANSI escape codes.
text: render colored text reports by using ANSI escape codes.
never: render report without color.
Defaults to 'auto'.
you can also specify the value with PYTEST_MD_REPORT_COLOR environment variable.
--md-report-margin=MARGIN
Margin size for each cell.
Defaults to 1.
you can also specify the value with PYTEST_MD_REPORT_MARGIN environment variable.
--md-report-zeros={number,empty}
Rendering method for results of zero values.
number: render as a digit number (0).
empty: not rendering.
Defaults to 'empty' when CI environment variable is set to TRUE (case insensitive);
otherwise 'number'.
you can also specify the value with PYTEST_MD_REPORT_ZEROS environment variable.
--md-report-success-color=MD_REPORT_SUCCESS_COLOR
Text color of succeeded results.
Specify a color name (one of the black/red/green/yellow/blue/magenta/cyan/white/lightblack/lightred/lightgreen/lightyellow/lightblue/lightmagenta/lightcyan/lightwhite) or a
color code (e.g. #ff1020).
Defaults to 'light_green'.
you can also specify the value with PYTEST_MD_REPORT_SUCCESS_COLOR environment variable.
--md-report-skip-color=MD_REPORT_SKIP_COLOR
Text color of skipped results.
Specify a color name (one of the black/red/green/yellow/blue/magenta/cyan/white/lightblack/lightred/lightgreen/lightyellow/lightblue/lightmagenta/lightcyan/lightwhite) or a
color code (e.g. #ff1020).
Defaults to 'light_yellow'.
you can also specify the value with PYTEST_MD_REPORT_SKIP_COLOR environment variable.
--md-report-error-color=MD_REPORT_ERROR_COLOR
Text color of failed results.
Specify a color name (one of the black/red/green/yellow/blue/magenta/cyan/white/lightblack/lightred/lightgreen/lightyellow/lightblue/lightmagenta/lightcyan/lightwhite) or a
color code (e.g. #ff1020).
Defaults to 'light_red'.
you can also specify the value with PYTEST_MD_REPORT_ERROR_COLOR environment variable.


ini-options
--------------------------------------------
[pytest] ini-options in the first ``pytest.ini``/``tox.ini``/``setup.cfg``/``pyproject.toml (pytest 6.0.0 or later)`` file found:

::

md_report (bool): Create Markdown report.
md_report_verbose (string):
Verbosity level for pytest-md-report. If not set, use the verbosity level of pytest. Defaults to 0.
md_report_color (string):
How to color output reports. auto: render colored (text and background) reports using ANSI escape codes. text: render colored text reports by using ANSI escape codes. never:
render report without color. Defaults to 'auto'.
md_report_output (string):
Path to a file to the outputs test report. Overwrite a file content if the file already exists.
md_report_tee (string):
output test report for both standard output and a file.
md_report_margin (string):
Margin size for each cell. Defaults to 1.
md_report_zeros (string):
Rendering method for results of zero values. number: render as a digit number (0). empty: not rendering. Defaults to 'empty' when CI environment variable is set to TRUE (case
insensitive); otherwise 'number'.
md_report_success_color (string):
Text color of succeeded results. Specify a color name (one of the
black/red/green/yellow/blue/magenta/cyan/white/lightblack/lightred/lightgreen/lightyellow/lightblue/lightmagenta/lightcyan/lightwhite) or a color code (e.g. #ff1020). Defaults
to 'light_green'.
md_report_skip_color (string):
Text color of skipped results. Specify a color name (one of the
black/red/green/yellow/blue/magenta/cyan/white/lightblack/lightred/lightgreen/lightyellow/lightblue/lightmagenta/lightcyan/lightwhite) or a color code (e.g. #ff1020). Defaults
to 'light_yellow'.
md_report_error_color (string):
Text color of failed results. Specify a color name (one of the
black/red/green/yellow/blue/magenta/cyan/white/lightblack/lightred/lightgreen/lightyellow/lightblue/lightmagenta/lightcyan/lightwhite) or a color code (e.g. #ff1020). Defaults
to 'light_red'.


Dependencies
============================================
- Python 3.7+
- `Python package dependencies (automatically installed) <https://github.com/thombashi/pytest-md-report/network/dependencies>`__

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-md-report-0.3.2.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

pytest_md_report-0.3.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest-md-report-0.3.2.tar.gz.

File metadata

  • Download URL: pytest-md-report-0.3.2.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pytest-md-report-0.3.2.tar.gz
Algorithm Hash digest
SHA256 abe400bac1ab435c690ff0e164330007f050f963923c692384ff96d08f3b083a
MD5 0f097b5d40f1838fd708accd37a2743a
BLAKE2b-256 a0b655edc3abed9bbc045cdaf7840c9b7b24515faf3e90e47cd137e20bc5dc5c

See more details on using hashes here.

File details

Details for the file pytest_md_report-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_md_report-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b99c2e9b816d0b4fc8c0cc88e9e05b007f98220625731ce62e5534847efdfcdf
MD5 ccd7e354b7382a8333cbdd569b2a470e
BLAKE2b-256 b3a75a7ccdf61421c95143eba0b9aaf2400d505d8a24dd5b648d903815b065bd

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