From 7c2ad2971d4fb87d62454112a93c564a2400a3f5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 12 Apr 2026 10:21:42 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20[testing=20improvement]=20Add=20?= =?UTF-8?q?tests=20for=20MPV=20IPC=20connection=20timeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added unit tests to verify that `MpvIPC.connect` correctly raises a `TimeoutError` when encountering `ConnectionRefusedError` or `FileNotFoundError` repeatedly until the timeout expires. Co-authored-by: dsetareh <15238752+dsetareh@users.noreply.github.com> --- tests/test_mpv_ipc.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_mpv_ipc.py diff --git a/tests/test_mpv_ipc.py b/tests/test_mpv_ipc.py new file mode 100644 index 0000000..0604174 --- /dev/null +++ b/tests/test_mpv_ipc.py @@ -0,0 +1,23 @@ +import unittest +from unittest.mock import patch +from tests.mpv_ipc import MpvIPC + +class TestMpvIPC(unittest.TestCase): + @patch('socket.socket.connect') + def test_connect_timeout_connection_refused(self, mock_connect): + mock_connect.side_effect = ConnectionRefusedError + ipc = MpvIPC() + # Set a small timeout for the test to run quickly + with self.assertRaises(TimeoutError): + ipc.connect('dummy_socket', connection_timeout=0.1) + + @patch('socket.socket.connect') + def test_connect_timeout_file_not_found(self, mock_connect): + mock_connect.side_effect = FileNotFoundError + ipc = MpvIPC() + # Set a small timeout for the test to run quickly + with self.assertRaises(TimeoutError): + ipc.connect('dummy_socket', connection_timeout=0.1) + +if __name__ == '__main__': + unittest.main()