refactor(): 重构动态用例生成逻辑并解耦核心组件

- 将 `CaseGenerator` 拆分为 `CaseDataLoader`(数据加载)和 `CaseGenerator`(用例构造),实现单一职责原则。
- 引入 `TestTemplateBase` 作为纯净的方法挂载容器,避免逻辑代码污染测试用例。
- 优化 YAML 解析流程,将文件扫描、参数化解析与 pytest 方法构建逻辑完全分离。
- 改进装饰器写法,使用更直观的 @ 语法糖处理 Allure 和 pytest.mark.parametrize。
- 增强执行日志,通过类型注解和实例引用记录更详细的运行上下文。
This commit is contained in:
2026-03-06 15:06:54 +08:00
parent 300b5a92d4
commit 69a96a0060
8 changed files with 258 additions and 34 deletions

View File

@@ -1,29 +1,24 @@
[tool.poetry]
[project]
name = "interfaceautotest"
version = "0.1.0"
description = ""
authors = ["NianJiu <t6i888@163.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
requires-python = ">=3.11"
dependencies = [
"requests>=2.32.3",
"pyyaml>=6.0.1",
"pytest>=8.3.3",
"jsonpath>=0.82.2",
"pymysql>=1.1.1",
"pytest-result-log>=1.2.2",
"allure-pytest>=2.13.5",
"cryptography>=44.0.2",
"python-dotenv>=0.9.9",
"pydantic>=2.12.5",
"lxml>=6.0.2",
]
requests = "^2.32.3"
pyyaml = "^6.0.2"
pytest = "^8.3.3"
jsonpath = "^0.82.2"
pymysql = "^1.1.1"
pytest-result-log = "^1.2.2"
allure-pytest = "^2.13.5"
cryptography = "^44.0.2"
dotenv = "^0.9.9"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[[tool.poetry.source]]
name = "tsinghua"
[[tool.uv.index]]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
priority = "primary"
default = true