Files
vrsub/tests/shared/__init__.py
T
cat-shark 8a715a8064 test: 按模块重写测试代码,删除旧平铺结构
按"测试规则"重写 tests/:一个模块一个目录、用例按数据→过程→验证三段书写、
不保留全局 conftest.py、测试过程只调用真实生产代码。

结构(73 个文件、30 个模块目录、477 用例):
- tests/nodes/  15 个模块目录(srt/whisper/ass/ffmpeg/frame_extract/vlm/
  subtitle_ocr/llm/llm_filter/subtitle_cleanup/subtitle_correction/
  proper_nouns/adaptive_pool/vad_profiler/echo);
- tests/app/    11 个模块目录(db/scheduler/batch/maintenance/registry/seed/
  storage/config/logging/main/routers 三组 API);
- tests/sdk/test_models、tests/web/test_crop、tests/shared(公共设施)。

测试数据随模块目录入库(tests/**/data/),删除根级 testdata/;.gitignore
的 data/ 改为 /data/,否则会连带忽略 tests/**/data/ 导致测试数据无法入库。

顺带发现并修复三个真实缺陷:
- nodes/srt.py:相邻条目缺少空行时把下一条时间轴吞进正文(静默错位),
  改为正文行遇时间戳行即报错;
- src/wov_app/scheduler.py:_file_size 只捕获 OSError,含 \x00 的产物 URI
  抛 ValueError 导致任务误判失败,改为同时捕获;
- nodes/subtitle_correction.py:生产代码依赖测试包解析 SRT,
  改用生产模块 nodes/srt.py。

真实模型/服务集成测试按外部状态跳过:新增 tests/shared/gpu_memory.py
(运行时探测显存、CUDA OOM 转跳过)与 tests/shared/llm_service.py
(无 Key / 余额 / 限流转跳过)。全量 477 passed。
2026-09-13 15:40:56 +08:00

19 lines
1012 B
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.
"""测试公共设施包(供各模块测试复用,不含业务断言与隐式全局副作用)。
本包提供三类公共能力,供需要真实数据或环境隔离的模块测试使用:
1. `realdata_contract`:真实数据契约(时间对齐素材、提示词规则素材的探查
与量化工具),只读取用户提供的真实文件,缺失时测试整体跳过;
2. `env_isolation`:环境与临时目录隔离,让依赖 `wov_app.config` 路径常量的
模块测试可以自建独立数据目录,不依赖全局 conftest;
3. `srt_entries`SRT 条目解析(秒为单位),供参考字幕与产物字幕共用。
规则要求:模块专用数据放各模块目录下的 `data/`,本包只放真正跨模块复用的
工具与跨模块共享素材(`tests/shared/data/`)。本包**不注册 pytest 钩子**
隔离能力由各模块测试显式调用,保证每个模块目录可独立运行。
"""
from __future__ import annotations
__all__: list[str] = []