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 <noreply@anthropic.com>
This commit is contained in:
@@ -575,7 +575,8 @@ class TestStateRecording:
|
|||||||
processor = ASRProcessor(state_manager=mock_state_manager)
|
processor = ASRProcessor(state_manager=mock_state_manager)
|
||||||
mock_state_manager.load.return_value = mock_state
|
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")):
|
with patch.object(processor, "_run_whisper", side_effect=Exception("Whisper error")):
|
||||||
input_data = ASRInput(
|
input_data = ASRInput(
|
||||||
content_id="BV1xx",
|
content_id="BV1xx",
|
||||||
@@ -583,7 +584,7 @@ class TestStateRecording:
|
|||||||
video_path=str(video_path)
|
video_path=str(video_path)
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception, match="Whisper error"):
|
||||||
await processor.process(input_data)
|
await processor.process(input_data)
|
||||||
|
|
||||||
# 应该调用 mark_step_failed
|
# 应该调用 mark_step_failed
|
||||||
|
|||||||
Reference in New Issue
Block a user