From 34f0052d61dc09f5df762b0e73df66175fa2d24f Mon Sep 17 00:00:00 2001 From: cat <1716967236@qq.com> Date: Fri, 18 Sep 2026 22:23:39 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=AF=B9=E9=BD=90=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E7=BC=BA=E7=9C=9F=E5=AE=9E=E7=B4=A0=E6=9D=90=E6=97=B6=E8=B7=B3?= =?UTF-8?q?=E8=BF=87=E8=80=8C=E4=B8=8D=E6=98=AF=E5=88=A4=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `tests/shared/data/alignment/` 里的媒体素材按规则不入库(.gitignore 掉 mp4/wav), 本机只拷了参考字幕时该用例会判红。按"外部环境状态缺失应跳过"的规则改为:目录在 但一个媒体文件都没有时 skip;有媒体但配对不全仍然失败(那才是真回归)。 --- tests/shared/test_alignment/test_alignment.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/shared/test_alignment/test_alignment.py b/tests/shared/test_alignment/test_alignment.py index 1f3b2b5..3be109c 100644 --- a/tests/shared/test_alignment/test_alignment.py +++ b/tests/shared/test_alignment/test_alignment.py @@ -45,6 +45,12 @@ def _sample_dir() -> Path | None: return directory if directory.is_dir() else None +MEDIA_SUFFIXES = { + ".wav", ".mp3", ".flac", ".m4a", ".aac", ".ogg", + ".mp4", ".mkv", ".mov", ".webm", ".ts", +} + + @pytest.mark.integration def test_real_alignment_candidates_discovered() -> None: """对齐素材探查:能找到成对的媒体与参考字幕(数据契约可用)。""" @@ -52,6 +58,12 @@ def test_real_alignment_candidates_discovered() -> None: directory = _sample_dir() if directory is None: pytest.skip("缺少 tests/shared/data/alignment 目录") + # 真实媒体素材不入库(.gitignore 掉的 mp4/wav),没拷过素材属环境状态:跳过 + # 而不是失败;只要有一个媒体文件就说明素材已就位,此时配对不全才是真回归。 + has_media = any(p.is_file() and p.suffix.lower() in MEDIA_SUFFIXES + for p in directory.iterdir()) + if not has_media: + pytest.skip("缺少真实媒体素材(按需从媒体库复制,不入库)") # 测试过程 candidates = alignment_candidates(directory)