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()