"""tests/api conftest — yun8 运输流程 API 造数 fixtures。 Usage: def test_xxx(yun8_config, yun8_pipeline, yun8_context): yun8_pipeline.run_driver_flow() """ import pytest @pytest.fixture(scope="session") def yun8_config(config): """yun8 运输流程 API 配置段(test_config.yaml 的 yun8_api)。""" return config["yun8_api"] @pytest.fixture(scope="class") def yun8_db(yun8_config): """class 级数据库长连接(造数 SQL 复用)。""" from tests.core.db_helper import Db db = Db() yield db db.close() @pytest.fixture(scope="class") def yun8_pipeline(yun8_config, yun8_db): """class 级 Yun8Pipeline — 5 个阶段用例共享同一份 Postman 变量上下文。 注意: 根 conftest 的 logger fixture 是 function 级, 这里直接用 get_logger(pipeline 内部亦如此)。 """ from tests.apis.yun8.pipeline import Yun8Pipeline pipe = Yun8Pipeline(yun8_config, yun8_db) pipe.set_auth(yun8_config["tokens"]["driver_token"], yun8_config["tokens"]["admin_token"]) yield pipe pipe.close() @pytest.fixture(scope="class") def yun8_context(): """跨阶段共享上下文:记录中断原因,供后续阶段 skip。""" return {"aborted": None}