@@ -137,57 +137,50 @@ async def _try_connect(self, **kwargs):
137137 if _system == 'Windows' :
138138 for tried in range (3 ):
139139 try :
140- return await self .cluster . connect (** kwargs )
140+ return await self .connect (** kwargs )
141141 except asyncpg .ConnectionDoesNotExistError :
142142 pass
143143
144- return await self .cluster . connect (** kwargs )
144+ return await self .connect (** kwargs )
145145
146146 async def test_auth_bad_user (self ):
147147 with self .assertRaises (
148148 asyncpg .InvalidAuthorizationSpecificationError ):
149- await self ._try_connect (user = '__nonexistent__' ,
150- database = 'postgres' ,
151- loop = self .loop )
149+ await self ._try_connect (user = '__nonexistent__' )
152150
153151 async def test_auth_trust (self ):
154- conn = await self .cluster .connect (
155- user = 'trust_user' , database = 'postgres' , loop = self .loop )
152+ conn = await self .connect (user = 'trust_user' )
156153 await conn .close ()
157154
158155 async def test_auth_reject (self ):
159156 with self .assertRaisesRegex (
160157 asyncpg .InvalidAuthorizationSpecificationError ,
161158 'pg_hba.conf rejects connection' ):
162- await self ._try_connect (
163- user = 'reject_user' , database = 'postgres' ,
164- loop = self .loop )
159+ await self ._try_connect (user = 'reject_user' )
165160
166161 async def test_auth_password_cleartext (self ):
167- conn = await self .cluster . connect (
168- user = 'password_user' , database = 'postgres' ,
169- password = 'correctpassword' , loop = self . loop )
162+ conn = await self .connect (
163+ user = 'password_user' ,
164+ password = 'correctpassword' )
170165 await conn .close ()
171166
172167 with self .assertRaisesRegex (
173168 asyncpg .InvalidPasswordError ,
174169 'password authentication failed for user "password_user"' ):
175170 await self ._try_connect (
176- user = 'password_user' , database = 'postgres' ,
177- password = 'wrongpassword' , loop = self . loop )
171+ user = 'password_user' ,
172+ password = 'wrongpassword' )
178173
179174 async def test_auth_password_md5 (self ):
180- conn = await self .cluster .connect (
181- user = 'md5_user' , database = 'postgres' , password = 'correctpassword' ,
182- loop = self .loop )
175+ conn = await self .connect (
176+ user = 'md5_user' , password = 'correctpassword' )
183177 await conn .close ()
184178
185179 with self .assertRaisesRegex (
186180 asyncpg .InvalidPasswordError ,
187181 'password authentication failed for user "md5_user"' ):
188182 await self ._try_connect (
189- user = 'md5_user' , database = 'postgres' , password = 'wrongpassword' ,
190- loop = self .loop )
183+ user = 'md5_user' , password = 'wrongpassword' )
191184
192185 async def test_auth_unsupported (self ):
193186 pass
@@ -494,11 +487,9 @@ async def test_connection_ssl_to_no_ssl_server(self):
494487 ssl_context .load_verify_locations (SSL_CA_CERT_FILE )
495488
496489 with self .assertRaisesRegex (ConnectionError , 'rejected SSL' ):
497- await self .cluster . connect (
490+ await self .connect (
498491 host = 'localhost' ,
499492 user = 'ssl_user' ,
500- database = 'postgres' ,
501- loop = self .loop ,
502493 ssl = ssl_context )
503494
504495 async def test_connection_ssl_unix (self ):
@@ -507,15 +498,17 @@ async def test_connection_ssl_unix(self):
507498
508499 with self .assertRaisesRegex (asyncpg .InterfaceError ,
509500 'can only be enabled for TCP addresses' ):
510- await self .cluster . connect (
501+ await self .connect (
511502 host = '/tmp' ,
512- loop = self .loop ,
513503 ssl = ssl_context )
514504
515505 async def test_connection_implicit_host (self ):
516- conn_spec = self .cluster . get_connection_spec ()
506+ conn_spec = self .get_connection_spec ()
517507 con = await asyncpg .connect (
518- port = conn_spec .get ('port' ), database = 'postgres' , loop = self .loop )
508+ port = conn_spec .get ('port' ),
509+ database = conn_spec .get ('database' ),
510+ user = conn_spec .get ('user' ),
511+ loop = self .loop )
519512 await con .close ()
520513
521514
@@ -576,11 +569,9 @@ async def test_ssl_connection_custom_context(self):
576569 ssl_context = ssl .SSLContext (ssl .PROTOCOL_SSLv23 )
577570 ssl_context .load_verify_locations (SSL_CA_CERT_FILE )
578571
579- con = await self .cluster . connect (
572+ con = await self .connect (
580573 host = 'localhost' ,
581574 user = 'ssl_user' ,
582- database = 'postgres' ,
583- loop = self .loop ,
584575 ssl = ssl_context )
585576
586577 try :
@@ -595,11 +586,9 @@ async def test_ssl_connection_custom_context(self):
595586
596587 async def test_ssl_connection_default_context (self ):
597588 with self .assertRaisesRegex (ssl .SSLError , 'verify failed' ):
598- await self .cluster . connect (
589+ await self .connect (
599590 host = 'localhost' ,
600591 user = 'ssl_user' ,
601- database = 'postgres' ,
602- loop = self .loop ,
603592 ssl = True )
604593
605594 async def test_ssl_connection_pool (self ):
0 commit comments