pytest-md
pytest-md is a pytest plugin designed for generating Markdown reports from pytest test results. It is currently at version 0.2.0 and receives updates with a moderate release cadence, indicating active maintenance.
Warnings
- gotcha Version 0.2.0 introduced the capability for 'individual test reports and errors'. While an enhancement, this change might alter the granular structure or content of the generated Markdown report compared to previous versions (e.g., 0.1.x), which could affect automated tools parsing these reports.
- gotcha As a pytest plugin, `pytest-md` automatically registers itself with pytest upon installation. Its primary functionality is exposed via command-line options (e.g., `--md report.md`) and does not typically require importing any symbols into your test files or Python code for basic usage.
- gotcha Be aware of potential confusion with 'pytest-md-report', a separate plugin that also generates Markdown reports but often in a tabular format with different configuration options. Ensure you install and use the correct plugin for your desired report style and features.
- gotcha `pytest-md` can integrate with `pytest-emoji` for richer, emoji-laden reports. If you desire emojis in your Markdown output, `pytest-emoji` must be installed separately in addition to `pytest-md`.
Install
-
pip install pytest-md
Imports
- pytest-md plugin
No direct Python import is typically needed; the plugin is loaded by pytest upon installation.
Quickstart
# tests/test_example.py
import pytest
import random
def test_passed():
assert True
def test_failed():
assert False
@pytest.mark.skip(reason="demonstrating skip")
def test_skipped():
assert True
@pytest.mark.xfail(reason="demonstrating xfail")
def test_xfail():
assert False
@pytest.mark.xfail(reason="demonstrating xpass", strict=True)
def test_xpass():
assert 0.0 < random.random() < 1.0 # This test will actually pass, but is marked xfail.
def test_error_division_by_zero():
1 / 0
# To generate a Markdown report, run pytest from your terminal:
# pytest --md report.md