test: 对齐用例缺真实素材时跳过而不是判失败
`tests/shared/data/alignment/` 里的媒体素材按规则不入库(.gitignore 掉 mp4/wav), 本机只拷了参考字幕时该用例会判红。按"外部环境状态缺失应跳过"的规则改为:目录在 但一个媒体文件都没有时 skip;有媒体但配对不全仍然失败(那才是真回归)。
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user