pytest-vw 项目使用教程

pytest-vw 项目使用教程

pytest-vwpytest-vw makes your failing test cases succeed under CI tools scrutiny项目地址:https://gitcode.com/gh_mirrors/py/pytest-vw

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

pytest-vw/
├── .gitignore
├── .travis.yml
├── LICENSE
├── MANIFEST.in
├── README.rst
├── conftest.py
├── pytest_volkswagen.py
├── setup.py
└── test_pytest_volkswagen.py
  • .gitignore: Git 忽略文件配置。
  • .travis.yml: Travis CI 配置文件。
  • LICENSE: 项目许可证文件,采用 MIT 许可证。
  • MANIFEST.in: 用于指定在打包时包含的文件。
  • README.rst: 项目说明文档。
  • conftest.py: pytest 配置文件,用于共享 fixtures 等。
  • pytest_volkswagen.py: 项目主文件,包含 pytest 插件的实现。
  • setup.py: 用于安装和分发项目的配置文件。
  • test_pytest_volkswagen.py: 测试文件,包含测试用例。

2. 项目的启动文件介绍

项目的启动文件是 pytest_volkswagen.py,该文件包含了 pytest 插件的主要实现。它通过检测 CI 环境,使得在 CI 工具中失败的测试用例能够成功通过。

# pytest_volkswagen.py
import os
import pytest

def pytest_configure(config):
    if os.getenv('CI'):
        config.addinivalue_line('markers', 'vw: make failing tests succeed in CI environments')

def pytest_runtest_makereport(item, call):
    if os.getenv('CI') and call.excinfo and call.excinfo.typename != 'Skipped':
        call.excinfo = None

3. 项目的配置文件介绍

  • setup.py: 该文件用于配置项目的安装和分发。它包含了项目的基本信息、依赖关系以及如何安装项目。
# setup.py
from setuptools import setup, find_packages

setup(
    name='pytest-vw',
    version='0.1.0',
    description='VW makes failing test cases succeed in continuous integration tools',
    long_description=open('README.rst').read(),
    author='Florian Bruhin',
    author_email='me@the-compiler.org',
    url='https://github.com/The-Compiler/pytest-vw',
    license='MIT',
    py_modules=['pytest_volkswagen'],
    install_requires=['pytest'],
    entry_points={'pytest11': ['vw = pytest_volkswagen']},
    classifiers=[
        'Development Status :: 4 - Beta',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: MIT License',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
        'Topic :: Software Development :: Testing',
    ],
)
  • conftest.py: 该文件用于共享 pytest 的 fixtures 和其他配置。
# conftest.py
import pytest

def pytest_addoption(parser):
    parser.addoption('--ci', action='store_true', help='Enable CI mode')

以上是 pytest-vw 项目的基本使用教程,包含了项目的目录结构、启动文件和配置文件的介绍。希望对你有所帮助!

pytest-vwpytest-vw makes your failing test cases succeed under CI tools scrutiny项目地址:https://gitcode.com/gh_mirrors/py/pytest-vw

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

咎竹峻Karen

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

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

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

打赏作者

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

抵扣说明:

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

余额充值