@@ -180,23 +180,17 @@ async def test_repr_contains_db_info_tcp(self):
180
180
async with self .get_pool (
181
181
connection_kwargs = connection_kwargs , connection_class = redis .Connection
182
182
) 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 )
188
185
189
186
async def test_repr_contains_db_info_unix (self ):
190
187
connection_kwargs = {"path" : "/abc" , "db" : 1 , "client_name" : "test-client" }
191
188
async with self .get_pool (
192
189
connection_kwargs = connection_kwargs ,
193
190
connection_class = redis .UnixDomainSocketConnection ,
194
191
) 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 )
200
194
201
195
202
196
class TestBlockingConnectionPool :
@@ -293,23 +287,17 @@ def test_repr_contains_db_info_tcp(self):
293
287
pool = redis .ConnectionPool (
294
288
host = "localhost" , port = 6379 , client_name = "test-client"
295
289
)
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 )
301
292
302
293
def test_repr_contains_db_info_unix (self ):
303
294
pool = redis .ConnectionPool (
304
295
connection_class = redis .UnixDomainSocketConnection ,
305
296
path = "abc" ,
306
297
client_name = "test-client" ,
307
298
)
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 )
313
301
314
302
315
303
class TestConnectionPoolURLParsing :
@@ -659,7 +647,10 @@ def test_connect_from_url_tcp(self):
659
647
connection = redis .Redis .from_url ("redis://localhost" )
660
648
pool = connection .connection_pool
661
649
662
- assert re .match ("(.*)<(.*)<(.*)>>" , repr (pool )).groups () == (
650
+ print (repr (pool ))
651
+ assert re .match (
652
+ r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >" , repr (pool ), re .VERBOSE
653
+ ).groups () == (
663
654
"ConnectionPool" ,
664
655
"Connection" ,
665
656
"host=localhost,port=6379,db=0" ,
@@ -669,7 +660,9 @@ def test_connect_from_url_unix(self):
669
660
connection = redis .Redis .from_url ("unix:///path/to/socket" )
670
661
pool = connection .connection_pool
671
662
672
- assert re .match ("(.*)<(.*)<(.*)>>" , repr (pool )).groups () == (
663
+ assert re .match (
664
+ r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >" , repr (pool ), re .VERBOSE
665
+ ).groups () == (
673
666
"ConnectionPool" ,
674
667
"UnixDomainSocketConnection" ,
675
668
"path=/path/to/socket,db=0" ,
0 commit comments