1212from openlrc .transcribe import TranscriptionInfo
1313from openlrc .utils import extend_filename
1414
15+ DATA_DIR = Path (__file__ ).parent / "data"
16+
1517# Shared test config — avoids repeating these in every test method.
1618_TEST_TRANSCRIPTION = TranscriptionConfig (whisper_model = "tiny" , compute_type = "default" , device = "cpu" )
1719
@@ -64,9 +66,9 @@ def _mock_create_chatbot(*args, **kwargs):
6466@patch ("openlrc.agents.create_chatbot" , side_effect = _mock_create_chatbot )
6567class TestLRCer (unittest .TestCase ):
6668 def setUp (self ) -> None :
67- self .audio_path = Path ( "data/ test_audio.wav")
68- self .video_path = Path ( "data/ test_video.mp4")
69- self .nospeech_video_path = Path ( "data/ test_nospeech_video.mp4")
69+ self .audio_path = DATA_DIR / " test_audio.wav"
70+ self .video_path = DATA_DIR / " test_video.mp4"
71+ self .nospeech_video_path = DATA_DIR / " test_nospeech_video.mp4"
7072
7173 def tearDown (self ) -> None :
7274 def clear_paths (input_path ):
@@ -89,7 +91,7 @@ def clear_paths(input_path):
8991
9092 self .video_path .with_suffix (".wav" ).unlink (missing_ok = True )
9193
92- shutil .rmtree ("data/ preprocessed" , ignore_errors = True )
94+ shutil .rmtree (DATA_DIR / " preprocessed" , ignore_errors = True )
9395
9496 # ------------------------------------------------------------------
9597 # Pipeline tests (using new config API)
@@ -115,22 +117,22 @@ def test_multiple_audio_transcription_translation(self, _mock_chatbot):
115117 def test_audio_file_not_found (self , _mock_chatbot ):
116118 lrcer = LRCer (transcription = _TEST_TRANSCRIPTION )
117119 with self .assertRaises (FileNotFoundError ):
118- lrcer .run ("data/ invalid.mp3" )
120+ lrcer .run (DATA_DIR / " invalid.mp3" )
119121
120122 @patch (
121123 "openlrc.translate.LLMTranslator.translate" , MagicMock (return_value = ["test translation1" , "test translation2" ])
122124 )
123125 def test_video_file_transcription_translation (self , _mock_chatbot ):
124126 lrcer = LRCer (transcription = _TEST_TRANSCRIPTION )
125- result = lrcer .run ("data/ test_video.mp4" )
127+ result = lrcer .run (DATA_DIR / " test_video.mp4" )
126128 self .assertTrue (result )
127129
128130 @patch (
129131 "openlrc.translate.LLMTranslator.translate" , MagicMock (return_value = ["test translation1" , "test translation2" ])
130132 )
131133 def test_nospeech_video_file_transcription_translation (self , _mock_chatbot ):
132134 lrcer = LRCer (transcription = _TEST_TRANSCRIPTION )
133- result = lrcer .run ("data/ test_nospeech_video.mp4" )
135+ result = lrcer .run (DATA_DIR / " test_nospeech_video.mp4" )
134136 self .assertTrue (result )
135137
136138 @patch ("openlrc.translate.LLMTranslator.translate" , MagicMock (side_effect = Exception ("test exception" )))
@@ -142,7 +144,7 @@ def test_translation_error(self, _mock_chatbot):
142144 @patch ("openlrc.translate.LLMTranslator.translate" , MagicMock (side_effect = Exception ("test exception" )))
143145 def test_skip_translation (self , _mock_chatbot ):
144146 lrcer = LRCer (transcription = _TEST_TRANSCRIPTION )
145- result = lrcer .run ("data/ test_video.mp4" , skip_trans = True )
147+ result = lrcer .run (DATA_DIR / " test_video.mp4" , skip_trans = True )
146148 self .assertTrue (result )
147149
148150 @patch (
0 commit comments