From ec533af9c1c6e156a1fe754fddc2095ebdba8554 Mon Sep 17 00:00:00 2001 From: Shalabh Chaturvedi Date: Thu, 25 Aug 2022 10:47:52 -0700 Subject: Fix incompatibility with redis in disconnect() (#1589) * Accept *args in disconnect() * Add test for redis connection timeout error --- t/integration/test_redis.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't') diff --git a/t/integration/test_redis.py b/t/integration/test_redis.py index 169a32dc..b2ae5ab8 100644 --- a/t/integration/test_redis.py +++ b/t/integration/test_redis.py @@ -1,6 +1,7 @@ from __future__ import annotations import os +import socket from time import sleep import pytest @@ -134,3 +135,18 @@ class test_RedisPriority(BasePriority): @pytest.mark.flaky(reruns=5, reruns_delay=2) class test_RedisMessage(BaseMessage): pass + + +@pytest.mark.env('redis') +def test_RedisConnectTimeout(monkeypatch): + # simulate a connection timeout for a new connection + def connect_timeout(self): + raise socket.timeout + monkeypatch.setattr( + redis.connection.Connection, "_connect", connect_timeout) + + # ensure the timeout raises a TimeoutError + with pytest.raises(redis.exceptions.TimeoutError): + # note the host/port here is irrelevant because + # connect will raise a socket.timeout + kombu.Connection('redis://localhost:12345').connect() -- cgit v1.2.1