pytest-bdd 项目使用教程
pytest-bddBDD library for the py.test runner项目地址:https://gitcode.com/gh_mirrors/py/pytest-bdd
1. 项目的目录结构及介绍
pytest-bdd 项目的目录结构如下:
pytest-bdd/
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── MANIFEST.in
├── README.md
├── docs/
│ ├── conf.py
│ ├── index.rst
│ └── ...
├── pytest_bdd/
│ ├── __init__.py
│ ├── model.py
│ ├── parser.py
│ ├── scenario.py
│ ├── step_registry.py
│ └── ...
├── setup.cfg
├── setup.py
└── tests/
├── conftest.py
├── test_example.py
└── ...
主要目录和文件介绍:
- CHANGELOG.md: 记录项目的版本变更历史。
- CONTRIBUTING.md: 指导如何为项目贡献代码。
- LICENSE: 项目的开源许可证。
- README.md: 项目的基本介绍和使用说明。
- docs/: 包含项目的文档文件,使用 Sphinx 生成。
- pytest_bdd/: 核心代码目录,包含项目的所有 Python 模块。
- setup.cfg: 项目的配置文件,用于打包和分发。
- setup.py: 项目的安装脚本。
- tests/: 包含项目的测试用例。
2. 项目的启动文件介绍
pytest-bdd 项目的启动文件主要是 setup.py
和 pytest_bdd/__init__.py
。
setup.py
setup.py
是 Python 项目的标准安装脚本,用于安装和分发项目。它通常包含项目的元数据(如名称、版本、依赖等)和安装指令。
from setuptools import setup, find_packages
setup(
name='pytest-bdd',
version='4.0.2',
description='BDD for pytest',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Pytest-BDD Developers',
url='https://github.com/pytest-dev/pytest-bdd',
packages=find_packages(exclude=['tests']),
install_requires=[
'pytest>=3.0.0',
'six',
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Framework :: Pytest',
'Intended Audience :: Developers',
'Topic :: Software Development :: Testing',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Operating System :: OS Independent',
'License :: OSI Approved :: MIT License',
],
entry_points={
'pytest11': [
'bdd = pytest_bdd.plugin',
],
},
)
pytest_bdd/init.py
pytest_bdd/__init__.py
是 pytest-bdd 包的初始化文件,定义了包的版本和一些基本配置。
__version__ = '4.0.2'
3. 项目的配置文件介绍
pytest-bdd 项目的配置文件主要是 setup.cfg
。
setup.cfg
setup.cfg
是 Python 项目的配置文件,用于指定打包和分发的配置选项。它包含了一些常用的配置,如测试、代码风格检查等。
[metadata]
name = pytest-bdd
version = attr: pytest_bdd.__version__
description = BDD for pytest
long_description = file: README.md
long_description_content_type = text/markdown
author = Pytest-BDD Developers
url = https://github.com/pytest-dev/pytest-bdd
license = MIT
[options]
packages = find:
install_requires =
pytest>=3.0.0
six
[options.extras_require]
docs =
pytest-bddBDD library for the py.test runner项目地址:https://gitcode.com/gh_mirrors/py/pytest-bdd