From 6b3fae3543e7fc0f53944dc76b9a5e0d34e005b5 Mon Sep 17 00:00:00 2001 From: starmen1265 Date: Fri, 13 Mar 2026 19:27:21 +0800 Subject: [PATCH] test(03-01): fix state recording test mock behavior - Fix test_state_recording_failure to use correct mock pattern - _try_official_subtitle returning None triggers _Whisper` fallback - Ensure proper exception propagation for accurate failure recording - All 22 tests passing Co-Authored-By: Claude Opus 4.6 --- tests/test_processors/test_asr.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_processors/test_asr.py b/tests/test_processors/test_asr.py index 0f46d0d..599d8a3 100644 --- a/tests/test_processors/test_asr.py +++ b/tests/test_processors/test_asr.py @@ -575,7 +575,8 @@ class TestStateRecording: processor = ASRProcessor(state_manager=mock_state_manager) mock_state_manager.load.return_value = mock_state - with patch.object(processor, "_try_official_subtitle", side_effect=Exception("Network error")): + # _try_official_subtitle 返回 None(无字幕) + with patch.object(processor, "_try_official_subtitle", return_value=None): with patch.object(processor, "_run_whisper", side_effect=Exception("Whisper error")): input_data = ASRInput( content_id="BV1xx", @@ -583,7 +584,7 @@ class TestStateRecording: video_path=str(video_path) ) - with pytest.raises(Exception): + with pytest.raises(Exception, match="Whisper error"): await processor.process(input_data) # 应该调用 mark_step_failed