03e152baab
目录结构: tests/web/admin/ 管理端 (Playwright) tests/web/mini_program/ 司机端小程序 (Playwright/微信 WebView) tests/app/driver_android/ 司机安卓 (Appium) tests/app/shipper_android/ 货主安卓 (Appium) tests/app/driver_ios/ 司机苹果 (Appium) tests/app/shipper_ios/ 货主苹果 (Appium) 公共模块: tests/app/_shared.py driver+ensure_logged_in 工厂 tests/app/_base_page.py App Page Object 基类 配置: test_config.yaml 拆分为 6 个独立 section + 货主账号
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
"""根级 conftest — 全局 fixture:配置加载、日志。
|
||
|
||
Usage:
|
||
def test_xxx(admin_config): # 管理端配置
|
||
def test_xxx(driver_android_config): # 司机安卓配置
|
||
"""
|
||
|
||
from pathlib import Path
|
||
import sys
|
||
|
||
import pytest
|
||
|
||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||
|
||
|
||
@pytest.fixture(scope="session")
|
||
def config():
|
||
"""全局配置(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)
|
||
|
||
|
||
# ═══════════════════════════════════════════════════════════════════
|
||
# 各端配置 fixture(从 config 中摘取对应 section)
|
||
# ═══════════════════════════════════════════════════════════════════
|
||
|
||
@pytest.fixture(scope="session")
|
||
def admin_config(config):
|
||
"""管理端 (Playwright) 配置。"""
|
||
return config["admin"]
|
||
|
||
@pytest.fixture(scope="session")
|
||
def mini_program_config(config):
|
||
"""司机端小程序 (Playwright) 配置。"""
|
||
return config["mini_program"]
|
||
|
||
@pytest.fixture(scope="session")
|
||
def driver_android_config(config):
|
||
"""司机安卓端 (Appium) 配置。"""
|
||
return config["driver_android"]
|
||
|
||
@pytest.fixture(scope="session")
|
||
def shipper_android_config(config):
|
||
"""货主安卓端 (Appium) 配置。"""
|
||
return config["shipper_android"]
|
||
|
||
@pytest.fixture(scope="session")
|
||
def driver_ios_config(config):
|
||
"""司机苹果端 (Appium) 配置。"""
|
||
return config["driver_ios"]
|
||
|
||
@pytest.fixture(scope="session")
|
||
def shipper_ios_config(config):
|
||
"""货主苹果端 (Appium) 配置。"""
|
||
return config["shipper_ios"]
|