aade9e39d0
- tests/config: 环境配置 (.yaml) + 配置加载器 - tests/utils: 日志工具 + 测试数据生成器 - tests/web: Playwright conftest + Page Object 基类 + 登录页 + 导航栏组件 + 登录用例(6条) - tests/app: Appium conftest + Page Object 基类 + 司机端首页 + 登录用例(3条) - pytest.ini: markers(p0/p1/p2/smoke/web/app) + 运行配置 - 所有用例按最佳实践采用 Page Object 模式 + data-testid 优先定位 + 失败自动截图
28 lines
801 B
Python
28 lines
801 B
Python
"""根级 conftest — 全局 fixture:配置加载、日志、测试数据清理。
|
||
|
||
自动应用于 tests/ 下所有测试模块。
|
||
"""
|
||
|
||
from pathlib import Path
|
||
|
||
import pytest
|
||
|
||
# 将 tests/ 目录加入 Python path,确保 `from tests.xxx import yyy` 可用
|
||
import sys
|
||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||
|
||
|
||
@pytest.fixture(scope="session")
|
||
def config():
|
||
"""全局配置 fixture(session 级别,只加载一次)。"""
|
||
from tests.config.test_config import load_config
|
||
return load_config()
|
||
|
||
|
||
@pytest.fixture(scope="function")
|
||
def logger(request):
|
||
"""每个测试函数一个 logger,自动以模块名命名。"""
|
||
from tests.utils.logger import get_logger
|
||
module_name = request.module.__name__.replace("tests.", "")
|
||
return get_logger(module_name)
|