Files
InterfaceAutoTest/core/context.py
CNWei 6393414ab2 feat,fix(core,docs): 完善核心模块代码注释并添加架构改进文档
- 为 core 目录下主要模块 (models, context, creator, base_api, exchange, executor) 添加了详细的类和方法 Docstring。
   - 新增 docs/架构改进.md 文件。
2026-03-18 11:26:55 +08:00

47 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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):
"""
初始化变量仓库。
Args:
seed_file: 初始变量文件路径YAML格式用于加载种子数据。
"""
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"