import unittest from unittest import mock from hpr_stripper import asr class TestAsrResilience(unittest.TestCase): def test_missing_binary_returns_empty_list_not_exception(self): # Regression test: subprocess.run(["whisper", ...]) raises # FileNotFoundError when the binary isn't installed/on PATH, which # used to propagate and crash the whole detection pipeline instead # of being treated like any other "ASR unavailable" case. with mock.patch("subprocess.run", side_effect=FileNotFoundError("no such file")): result = asr.transcribe_clip("/tmp/does-not-matter.wav") self.assertEqual(result, []) def test_nonzero_returncode_returns_empty_list(self): fake_result = mock.Mock(returncode=1) with mock.patch("subprocess.run", return_value=fake_result): result = asr.transcribe_clip("/tmp/does-not-matter.wav") self.assertEqual(result, []) if __name__ == "__main__": unittest.main()