30 lines
833 B
Python
30 lines
833 B
Python
# 导出格式化工具:将测试用例转换为 YAML/CSV/XMind 格式
|
|
|
|
import yaml
|
|
import csv
|
|
import io
|
|
from typing import Any
|
|
|
|
|
|
def to_yaml(cases: list[dict]) -> str:
|
|
"""将用例集序列化为 YAML 字符串"""
|
|
# TODO: Phase 4 按实际 IR schema 调整输出结构
|
|
return yaml.dump(cases, allow_unicode=True, sort_keys=False)
|
|
|
|
|
|
def to_csv(cases: list[dict]) -> str:
|
|
"""将用例集序列化为 CSV 字符串"""
|
|
if not cases:
|
|
return ""
|
|
output = io.StringIO()
|
|
writer = csv.DictWriter(output, fieldnames=cases[0].keys())
|
|
writer.writeheader()
|
|
writer.writerows(cases)
|
|
return output.getvalue()
|
|
|
|
|
|
def to_xmind(cases: list[dict]) -> bytes:
|
|
"""将用例集导出为 XMind 文件(占位,Phase 4 实现)"""
|
|
# TODO: Phase 4 使用 xmind 库生成 .xmind 文件
|
|
return b""
|