From 031972639804ce4dddaf651bf0769355e7e14825 Mon Sep 17 00:00:00 2001 From: David Maier <60782329+dmaier-redislabs@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:14:13 +0200 Subject: [PATCH] Fixes CAE-333 (#3290) * Fixes CAE-333, which uncovered that the init method of the base class did override the initialization of the socket_timeout parameter. * Added missing blank lines * Removed blank line * Changed to quotes --------- Co-authored-by: vladvildanov Signed-off-by: Salvatore Mesoraca --- tests/test_connect.py | 17 +++++++++++++++++ valkey/connection.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/test_connect.py b/tests/test_connect.py index 57c0a2dba9..ac91f5a003 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -104,6 +104,23 @@ def test_tcp_ssl_tls12_custom_ciphers(tcp_address, ssl_ciphers): ) +""" +Addresses bug CAE-333 which uncovered that the init method of the base +class did override the initialization of the socket_timeout parameter. +""" + + +def test_unix_socket_with_timeout(): + conn = UnixDomainSocketConnection(socket_timeout=1000) + + # Check if the base class defaults were taken over. + assert conn.db == 0 + + # Verify if the timeout and the path is set correctly. + assert conn.socket_timeout == 1000 + assert conn.path == "" + + @pytest.mark.ssl @pytest.mark.skipif(not ssl.HAS_TLSv1_3, reason="requires TLSv1.3") def test_tcp_ssl_version_mismatch(tcp_address): diff --git a/valkey/connection.py b/valkey/connection.py index 07e004e17f..db68cd7da4 100644 --- a/valkey/connection.py +++ b/valkey/connection.py @@ -907,9 +907,9 @@ class UnixDomainSocketConnection(AbstractConnection): "Manages UDS communication to and from a Valkey server" def __init__(self, path="", socket_timeout=None, **kwargs): + super().__init__(**kwargs) self.path = path self.socket_timeout = socket_timeout - super().__init__(**kwargs) def repr_pieces(self): pieces = [("path", self.path), ("db", self.db)]