pytest-split 开源项目教程

pytest-split 开源项目教程

pytest-splitPytest plugin which splits the test suite to equally sized "sub suites" based on test execution time.项目地址:https://gitcode.com/gh_mirrors/py/pytest-split

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

pytest-split/
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── docs/
│   ├── conf.py
│   ├── index.rst
│   └── make.bat
├── pytest_split/
│   ├── __init__.py
│   ├── cli.py
│   ├── plugin.py
│   └── strategy.py
├── setup.cfg
├── setup.py
└── tests/
    ├── __init__.py
    ├── conftest.py
    ├── test_cli.py
    ├── test_plugin.py
    └── test_strategy.py
  • CHANGELOG.md: 记录项目的变更历史。
  • CONTRIBUTING.md: 指导如何为项目贡献代码。
  • LICENSE: 项目的开源许可证。
  • README.md: 项目的主介绍文档。
  • docs/: 项目的文档目录,包含 Sphinx 文档配置和源文件。
  • pytest_split/: 项目的主要代码目录,包含插件的核心逻辑。
  • setup.cfg: 项目的配置文件,用于打包和分发。
  • setup.py: 用于安装和分发项目的脚本。
  • tests/: 项目的测试代码目录,包含各种测试用例。

2. 项目的启动文件介绍

项目的启动文件是 pytest_split/cli.py,它定义了命令行接口(CLI),允许用户通过命令行运行 pytest-split。

# pytest_split/cli.py

import click
from pytest_split import plugin

@click.command()
@click.option('--group-size', type=int, required=True, help='Number of tests in each group')
@click.option('--total-groups', type=int, required=True, help='Total number of groups')
@click.option('--group-id', type=int, required=True, help='ID of the group to run')
def main(group_size, total_groups, group_id):
    plugin.run(group_size, total_groups, group_id)

if __name__ == '__main__':
    main()

3. 项目的配置文件介绍

项目的配置文件是 setup.cfg,它包含了项目的元数据和配置信息,用于打包和分发。

[metadata]
name = pytest-split
version = attr: pytest_split.__version__
description = Split pytest suites into separate runs
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/jerry-git/pytest-split
author = Jerry Pussinen
author_email = jerry.pussinen@gmail.com
license = MIT
classifiers =
    Development Status :: 5 - Production/Stable
    Intended Audience :: Developers
    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

[options]
packages = find:
install_requires =
    pytest>=6.0
    click>=7.0

[options.entry_points]
pytest11 =
    pytest_split = pytest_split.plugin
  • metadata: 包含项目的名称、版本、描述、作者等信息。
  • options: 指定需要打包的包和依赖项。
  • options.entry_points: 定义 pytest 插件的入口点。

pytest-splitPytest plugin which splits the test suite to equally sized "sub suites" based on test execution time.项目地址:https://gitcode.com/gh_mirrors/py/pytest-split

  • 19
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

农彩媛Louise

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

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

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

打赏作者

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

抵扣说明:

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

余额充值