Skip to content

Commit

Permalink
Fix: mock pyaudio for ci to pass the server tests
Browse files Browse the repository at this point in the history
  • Loading branch information
makaveli10 authored Mar 15, 2024
1 parent 37d7f2e commit 7c7a446
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def test_recv_audio_exception_handling(self, mock_websocket):
class TestServerInferenceAccuracy(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.mock_pyaudio_patch = mock.patch('pyaudio.PyAudio')
cls.mock_pyaudio = cls.mock_pyaudio_patch.start()
cls.mock_pyaudio.return_value.open.return_value = mock.MagicMock()

cls.server_process = subprocess.Popen(["python", "run_server.py"])
time.sleep(2)

Expand All @@ -77,11 +81,7 @@ def tearDownClass(cls):
cls.server_process.terminate()
cls.server_process.wait()

@mock.patch('pyaudio.PyAudio')
def setUp(self, mock_pyaudio):
self.mock_pyaudio = mock_pyaudio.return_value
self.mock_stream = mock.MagicMock()
self.mock_pyaudio.open.return_value = self.mock_stream
def setUp(self):
self.metric = evaluate.load("wer")
self.normalizer = EnglishTextNormalizer()

Expand Down Expand Up @@ -117,6 +117,7 @@ def test_simultaneous_inference(self):
self.check_prediction("transcript1.srt")
self.check_prediction("transcript2.srt")


class TestExceptionHandling(unittest.TestCase):
def setUp(self):
self.server = TranscriptionServer()
Expand Down

0 comments on commit 7c7a446

Please sign in to comment.