pytest-json-report 项目教程

pytest-json-report 项目教程

pytest-json-report 🗒️ A pytest plugin to report test results as JSON 项目地址: https://gitcode.com/gh_mirrors/py/pytest-json-report

1. 项目的目录结构及介绍

pytest-json-report/
├── github/
│   └── workflows/
├── tests/
├── .coveragerc
├── .gitignore
├── LICENSE
├── README.md
├── sample_report.json
├── setup.py
└── tox.ini

目录结构介绍

  • github/workflows/: 包含GitHub Actions的工作流配置文件。
  • tests/: 包含项目的测试文件。
  • .coveragerc: 代码覆盖率配置文件。
  • .gitignore: Git忽略文件配置。
  • LICENSE: 项目的开源许可证文件。
  • README.md: 项目的介绍和使用说明。
  • sample_report.json: 示例的JSON报告文件。
  • setup.py: 项目的安装配置文件。
  • tox.ini: Tox配置文件,用于自动化测试。

2. 项目的启动文件介绍

setup.py

setup.py 是Python项目的标准安装文件,用于定义项目的元数据和依赖项。通过运行 python setup.py install 可以安装该项目。

from setuptools import setup, find_packages

setup(
    name='pytest-json-report',
    version='1.0.0',
    description='A pytest plugin to report test results as JSON',
    long_description=open('README.md').read(),
    long_description_content_type='text/markdown',
    author='numirias',
    author_email='numirias@example.com',
    url='https://github.com/numirias/pytest-json-report',
    packages=find_packages(),
    install_requires=[
        'pytest>=3.5.0',
    ],
    entry_points={
        'pytest11': [
            'json-report = pytest_jsonreport.plugin',
        ],
    },
    classifiers=[
        'Framework :: Pytest',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
        'Programming Language :: Python :: 3.8',
        'Programming Language :: Python :: 3.9',
    ],
)

3. 项目的配置文件介绍

.coveragerc

.coveragerc 文件用于配置代码覆盖率工具 coverage.py

[run]
omit =
    */tests/*
    */setup.py

[report]
exclude_lines =
    pragma: no cover
    def __repr__
    if self.debug
    if __name__ == .__main__.:

tox.ini

tox.ini 文件用于配置 tox,一个用于自动化测试的工具。

[tox]
envlist = py36,py37,py38,py39

[testenv]
deps =
    pytest
    pytest-cov
commands =
    pytest --cov=pytest_jsonreport --cov-report=term-missing

通过这些配置文件,可以确保项目在不同的Python版本下进行测试,并且生成代码覆盖率报告。

pytest-json-report 🗒️ A pytest plugin to report test results as JSON 项目地址: https://gitcode.com/gh_mirrors/py/pytest-json-report

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

潘惟妍

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值