docs: 为全部代码补充中文注释并加入 AGENTS 注释规范
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
"""SRT 转 ASS 节点测试。
|
||||
|
||||
覆盖 SRT 解析、ASS 写入、畸形输入、缺失输入和入口点启动等真实代码路径。
|
||||
"""
|
||||
|
||||
import runpy
|
||||
from pathlib import Path
|
||||
|
||||
@@ -18,6 +23,7 @@ SAMPLE_SRT = """
|
||||
|
||||
|
||||
def test_parse_and_write(tmp_path) -> None:
|
||||
"""验证多行字幕会被解析并通过左右眼样式写出。"""
|
||||
entries = parse_srt(SAMPLE_SRT)
|
||||
assert len(entries) == 2
|
||||
assert entries[0][2] == r"第一行\N第二行"
|
||||
@@ -33,6 +39,7 @@ def test_parse_and_write(tmp_path) -> None:
|
||||
|
||||
|
||||
def test_parse_malformed(tmp_path) -> None:
|
||||
"""验证畸形 SRT 不会抛出异常且返回空条目或忽略坏行。"""
|
||||
source = tmp_path / "bad.srt"
|
||||
source.write_text("1\nnot a time line\n", encoding="utf-8")
|
||||
assert parse_srt(source.read_text(encoding="utf-8")) == []
|
||||
@@ -42,6 +49,7 @@ def test_parse_malformed(tmp_path) -> None:
|
||||
|
||||
|
||||
def test_invoke_success(tmp_path) -> None:
|
||||
"""验证成功调用会按指定分辨率输出 ASS 产物。"""
|
||||
source = tmp_path / "in.srt"
|
||||
source.write_text(SAMPLE_SRT, encoding="utf-8")
|
||||
response = invoke(
|
||||
@@ -58,6 +66,7 @@ def test_invoke_success(tmp_path) -> None:
|
||||
|
||||
|
||||
def test_invoke_missing_input(tmp_path) -> None:
|
||||
"""验证缺少 cn_srt_uri 时返回失败。"""
|
||||
response = invoke(
|
||||
InvokeRequest(
|
||||
run_id="run_2",
|
||||
@@ -70,6 +79,7 @@ def test_invoke_missing_input(tmp_path) -> None:
|
||||
|
||||
|
||||
def test_invoke_missing_file(tmp_path) -> None:
|
||||
"""验证 SRT 文件不存在时返回失败。"""
|
||||
response = invoke(
|
||||
InvokeRequest(
|
||||
run_id="run_3",
|
||||
@@ -82,6 +92,7 @@ def test_invoke_missing_file(tmp_path) -> None:
|
||||
|
||||
|
||||
def test_entrypoint(monkeypatch) -> None:
|
||||
"""验证 python -m wov_node_ass 会加载 ASS 节点 manifest。"""
|
||||
module_path = Path(__file__).resolve().parent.parent / "wov_node_ass" / "__main__.py"
|
||||
captured = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user