跳转到主要内容

pytest结果生成Markdown报告的插件

项目描述

pytest-md

pytest结果的Markdown报告插件 📝

安装

pytest-md 可在 PyPI 上使用,适用于Python 3.6及更高版本,您可以通过终端的 pip 安装到您的环境中。

$ pip install pytest-md

用法

以下示例代码生成了所有不同的pytest测试结果。

import random
import pytest


def test_failed():
    assert "emoji" == "hello world"


@pytest.mark.xfail
def test_xfailed():
    assert random.random() == 1.0


@pytest.mark.xfail
def test_xpassed():
    assert 0.0 < random.random() < 1.0


@pytest.mark.skip(reason="don't run this test")
def test_skipped():
    assert "pytest-emoji" != ""


@pytest.mark.parametrize(
    "name, expected",
    [
        ("Sara", "Hello Sara!"),
        ("Mat", "Hello Mat!"),
        ("Annie", "Hello Annie!"),
    ],
)
def test_passed(name, expected):
    assert f"Hello {name}!" == expected


@pytest.fixture
def number():
    return 1234 / 0


def test_error(number):
    assert number == number

安装 pytest-md 后,您现在可以生成以下Markdown测试报告

$ pytest --md report.md
# Test Report

*Report generated on 25-Feb-2019 at 17:18:29 by [pytest-md]*

[pytest-md]: https://github.com/hackebrot/pytest-md

## Summary

8 tests ran in 0.05 seconds

- 1 failed
- 3 passed
- 1 skipped
- 1 xfailed
- 1 xpassed
- 1 error

pytest-emoji

pytest-md 还与 pytest-emoji 集成,这允许我们在生成的Markdown测试报告中包含表情符号

$ pytest --emoji -v --md report.md
# Test Report

*Report generated on 25-Feb-2019 at 17:18:29 by [pytest-md]* 📝

[pytest-md]: https://github.com/hackebrot/pytest-md

## Summary

8 tests ran in 0.06 seconds ⏱

- 1 failed 😰
- 3 passed 😃
- 1 skipped 🙄
- 1 xfailed 😞
- 1 xpassed 😲
- 1 error 😡

致谢

本项目灵感来源于出色的 pytest-html 插件! 💻

社区

您想为 pytest-md 贡献吗?太棒了! 😃

请查看 good first issue 标签,其中包含适合您为 pytest-md 首次贡献的任务。您的贡献将受到高度赞赏!每一份贡献都很重要,并且将始终给予信用!了解谁已经为 pytest-md 贡献了 这里! 🌍🌏🌎

请注意,pytest-md 发布时附带了一份贡献者行为准则。通过参与此项目,您同意遵守其条款。

许可证

在MIT许可协议下分发,pytest-md 是免费和开源软件。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分布

pytest-md-0.2.0.tar.gz (6.0 kB 查看散列值)

上传时间 源代码

构建分布

pytest_md-0.2.0-py3-none-any.whl (6.1 kB 查看散列值)

上传时间 Python 3

由以下支持