Files
InterfaceAutoTest/core/context.py
CNWei d05757f7cc feat(core): 增强 Exchange,实现智能变量替换与类型保持
- 优化 conftest.py 增加异常日志记录和测试报告环境信息
 - 其他优化
2026-03-16 19:15:01 +08:00

41 lines
955 B
Python

#!/usr/bin/env python
# coding=utf-8
"""
@author: CNWei,ChenWei
@Software: PyCharm
@contact: t6g888@163.com
@file: context
@date: 2026/3/14 09:07
@desc:
"""
from dataclasses import dataclass
from typing import Any
from pathlib import Path
from core.exchange import Exchange
from core.session import Session
from commons.file_processors.yaml_processor import YamlProcessor
class VariableStore:
"""内存变量仓库:负责 L2 缓存与磁盘的唯一交互"""
def __init__(self, seed_file: Path):
self.seed_file = seed_file
self.processor = YamlProcessor(seed_file)
# 启动时仅加载一次
self.store: dict[str, Any] = self.processor.load() or {}
def persist(self):
"""测试结束时统一写盘"""
self.processor.save(self.store)
@dataclass
class ExecutionEnv:
"""环境上下文:持有共享资源"""
session: Session
store: VariableStore
exchanger: "Exchange"