Skip to content

Commit dcb2d98

Browse files
committed
Added test coverage
1 parent 05e48d3 commit dcb2d98

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_asyncio/test_sentinel.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,27 @@ async def mock_disconnect():
264264

265265
assert calls == 1
266266
await pool.disconnect()
267+
268+
269+
@pytest.mark.onlynoncluster
270+
async def test_repr_correctly_represents_connection_object(sentinel):
271+
pool = SentinelConnectionPool("mymaster", sentinel)
272+
connection = await pool.get_connection("PING")
273+
274+
assert (
275+
str(connection)
276+
== "<redis.asyncio.sentinel.SentinelManagedConnection,host=127.0.0.1,port=6379)>"
277+
)
278+
assert connection.connection_pool == pool
279+
await pool.release(connection)
280+
281+
del pool
282+
283+
assert (
284+
str(connection)
285+
== "<redis.asyncio.sentinel.SentinelManagedConnection,host=127.0.0.1,port=6379)>"
286+
)
287+
with pytest.raises(
288+
ReferenceError, match="weakly-referenced object no longer exists"
289+
):
290+
assert connection.connection_pool

0 commit comments

Comments
 (0)