diff --git a/health_check/contrib/redis.py b/health_check/contrib/redis.py index e4e37090..99eccffe 100644 --- a/health_check/contrib/redis.py +++ b/health_check/contrib/redis.py @@ -67,7 +67,7 @@ def __repr__(self): for key, value in sorted( client.connection_pool.connection_kwargs.items() ) - if key in {"host", "db"} + if key in {"host", "port", "db"} ) return f"Redis({safe_connection_str})" except AttributeError: diff --git a/tests/contrib/test_redis.py b/tests/contrib/test_redis.py index 7a8563c3..d8ea4b84 100644 --- a/tests/contrib/test_redis.py +++ b/tests/contrib/test_redis.py @@ -151,12 +151,13 @@ async def test_redis__validation_neither_param(self): def test_redis__repr_standard_client(self): """Verify repr includes host and db for a standard Redis client.""" + # https://github.com/codingjoe/django-health-check/issues/659 from redis.asyncio import Redis as RedisClient check = RedisHealthCheck( client_factory=lambda: RedisClient(host="myhost", port=6379, db=2) ) - assert repr(check) == "Redis(db=2, host='myhost')" + assert repr(check) == "Redis(db=2, host='myhost', port=6379)" def test_redis__repr_from_url(self): """Verify repr includes host and db when client is created via from_url."""