pytest-github-actions-annotate-failures 使用教程
1. 项目的目录结构及介绍
pytest-github-actions-annotate-failures/
├── README.md
├── pytest_github_actions_annotate_failures/
│ ├── __init__.py
│ ├── plugin.py
│ └── ...
├── tests/
│ ├── __init__.py
│ ├── test_plugin.py
│ └── ...
├── setup.py
├── requirements.txt
└── ...
- README.md: 项目介绍和使用说明。
- pytest_github_actions_annotate_failures/: 核心代码目录,包含插件的主要实现。
- init.py: 模块初始化文件。
- plugin.py: 插件的主要逻辑实现。
- tests/: 测试代码目录,包含插件的测试用例。
- init.py: 测试模块初始化文件。
- test_plugin.py: 针对插件的测试用例。
- setup.py: 项目安装脚本。
- requirements.txt: 项目依赖文件。
2. 项目的启动文件介绍
项目的启动文件是 pytest_github_actions_annotate_failures/plugin.py
。该文件包含了插件的主要逻辑,用于在 GitHub Actions 中注释失败的测试。
# pytest_github_actions_annotate_failures/plugin.py
import pytest
def pytest_configure(config):
# 配置插件
...
def pytest_runtest_makereport(item, call):
# 处理测试报告
...
3. 项目的配置文件介绍
项目的配置文件主要是 setup.py
和 requirements.txt
。
setup.py
setup.py
文件用于项目的安装和分发。
# setup.py
from setuptools import setup, find_packages
setup(
name='pytest-github-actions-annotate-failures',
version='0.2.0',
description='Pytest plugin to annotate failed tests with a workflow command for GitHub Actions',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='pytest-dev',
url='https://github.com/pytest-dev/pytest-github-actions-annotate-failures',
packages=find_packages(),
install_requires=open('requirements.txt').read().splitlines(),
entry_points={
'pytest11': [
'github_actions_annotate_failures = pytest_github_actions_annotate_failures.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',
],
)
requirements.txt
requirements.txt
文件列出了项目运行所需的依赖包。
pytest>=6.0.0
通过以上介绍,您可以更好地理解和使用 pytest-github-actions-annotate-failures
插件。希望本教程对您有所帮助!