MikiVL 70a56ede36 添加 macOS 安装包打包支持
- 重命名 parser.py → xl_parser.py 避免与 Python 3.9 stdlib 命名冲突
- 添加 PyInstaller spec 文件用于构建独立 Python 可执行文件
- 配置 electron-builder:extraResources 打包 Python binary、asarUnpack better-sqlite3
- 新增 build:python 和 dist 脚本,一键生成 DMG 安装包
- 更新测试:对齐新 fixture 结构和重命名后的模块

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 19:44:01 +08:00

37 lines
1.2 KiB
Python

import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../python"))
from xl_parser import parse_template
FIXTURE = os.path.join(os.path.dirname(__file__), "../fixtures/sample_template.xlsx")
def test_returns_sheets():
result = parse_template(FIXTURE)
assert "sheets" in result
assert "Sheet1" in result["sheets"]
def test_detects_placeholders():
result = parse_template(FIXTURE)
names = [p["name"] for p in result["placeholders"]]
assert "编号" in names
assert "姓名" in names
def test_ignores_non_placeholders():
result = parse_template(FIXTURE)
names = [p["name"] for p in result["placeholders"]]
assert "normal_value" not in names
def test_placeholder_has_cell_info():
result = parse_template(FIXTURE)
biaohao = next(p for p in result["placeholders"] if p["name"] == "编号")
assert biaohao["sheet"] == "Sheet1"
assert biaohao["cell"] == "A2"
def test_multiple_placeholders_detected():
result = parse_template(FIXTURE)
names = [p["name"] for p in result["placeholders"]]
assert "编号" in names
assert "姓名" in names
assert "部门" in names
assert "日期" in names