@@ -180,23 +180,17 @@ async def test_repr_contains_db_info_tcp(self):
180180 async with self .get_pool (
181181 connection_kwargs = connection_kwargs , connection_class = redis .Connection
182182 ) as pool :
183- expected = (
184- "ConnectionPool<Connection<"
185- "host=localhost,port=6379,db=1,client_name=test-client>>"
186- )
187- assert repr (pool ) == expected
183+ expected = "host=localhost,port=6379,db=1,client_name=test-client"
184+ assert expected in repr (pool )
188185
189186 async def test_repr_contains_db_info_unix (self ):
190187 connection_kwargs = {"path" : "/abc" , "db" : 1 , "client_name" : "test-client" }
191188 async with self .get_pool (
192189 connection_kwargs = connection_kwargs ,
193190 connection_class = redis .UnixDomainSocketConnection ,
194191 ) as pool :
195- expected = (
196- "ConnectionPool<UnixDomainSocketConnection<"
197- "path=/abc,db=1,client_name=test-client>>"
198- )
199- assert repr (pool ) == expected
192+ expected = "path=/abc,db=1,client_name=test-client"
193+ assert expected in repr (pool )
200194
201195
202196class TestBlockingConnectionPool :
@@ -293,23 +287,17 @@ def test_repr_contains_db_info_tcp(self):
293287 pool = redis .ConnectionPool (
294288 host = "localhost" , port = 6379 , client_name = "test-client"
295289 )
296- expected = (
297- "ConnectionPool<Connection<"
298- "host=localhost,port=6379,db=0,client_name=test-client>>"
299- )
300- assert repr (pool ) == expected
290+ expected = "host=localhost,port=6379,db=0,client_name=test-client"
291+ assert expected in repr (pool )
301292
302293 def test_repr_contains_db_info_unix (self ):
303294 pool = redis .ConnectionPool (
304295 connection_class = redis .UnixDomainSocketConnection ,
305296 path = "abc" ,
306297 client_name = "test-client" ,
307298 )
308- expected = (
309- "ConnectionPool<UnixDomainSocketConnection<"
310- "path=abc,db=0,client_name=test-client>>"
311- )
312- assert repr (pool ) == expected
299+ expected = "path=abc,db=0,client_name=test-client"
300+ assert expected in repr (pool )
313301
314302
315303class TestConnectionPoolURLParsing :
@@ -659,7 +647,10 @@ def test_connect_from_url_tcp(self):
659647 connection = redis .Redis .from_url ("redis://localhost" )
660648 pool = connection .connection_pool
661649
662- assert re .match ("(.*)<(.*)<(.*)>>" , repr (pool )).groups () == (
650+ print (repr (pool ))
651+ assert re .match (
652+ r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >" , repr (pool ), re .VERBOSE
653+ ).groups () == (
663654 "ConnectionPool" ,
664655 "Connection" ,
665656 "host=localhost,port=6379,db=0" ,
@@ -669,7 +660,9 @@ def test_connect_from_url_unix(self):
669660 connection = redis .Redis .from_url ("unix:///path/to/socket" )
670661 pool = connection .connection_pool
671662
672- assert re .match ("(.*)<(.*)<(.*)>>" , repr (pool )).groups () == (
663+ assert re .match (
664+ r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >" , repr (pool ), re .VERBOSE
665+ ).groups () == (
673666 "ConnectionPool" ,
674667 "UnixDomainSocketConnection" ,
675668 "path=/path/to/socket,db=0" ,
0 commit comments