@@ -137,57 +137,50 @@ async def _try_connect(self, **kwargs):
137
137
if _system == 'Windows' :
138
138
for tried in range (3 ):
139
139
try :
140
- return await self .cluster . connect (** kwargs )
140
+ return await self .connect (** kwargs )
141
141
except asyncpg .ConnectionDoesNotExistError :
142
142
pass
143
143
144
- return await self .cluster . connect (** kwargs )
144
+ return await self .connect (** kwargs )
145
145
146
146
async def test_auth_bad_user (self ):
147
147
with self .assertRaises (
148
148
asyncpg .InvalidAuthorizationSpecificationError ):
149
- await self ._try_connect (user = '__nonexistent__' ,
150
- database = 'postgres' ,
151
- loop = self .loop )
149
+ await self ._try_connect (user = '__nonexistent__' )
152
150
153
151
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' )
156
153
await conn .close ()
157
154
158
155
async def test_auth_reject (self ):
159
156
with self .assertRaisesRegex (
160
157
asyncpg .InvalidAuthorizationSpecificationError ,
161
158
'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' )
165
160
166
161
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' )
170
165
await conn .close ()
171
166
172
167
with self .assertRaisesRegex (
173
168
asyncpg .InvalidPasswordError ,
174
169
'password authentication failed for user "password_user"' ):
175
170
await self ._try_connect (
176
- user = 'password_user' , database = 'postgres' ,
177
- password = 'wrongpassword' , loop = self . loop )
171
+ user = 'password_user' ,
172
+ password = 'wrongpassword' )
178
173
179
174
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' )
183
177
await conn .close ()
184
178
185
179
with self .assertRaisesRegex (
186
180
asyncpg .InvalidPasswordError ,
187
181
'password authentication failed for user "md5_user"' ):
188
182
await self ._try_connect (
189
- user = 'md5_user' , database = 'postgres' , password = 'wrongpassword' ,
190
- loop = self .loop )
183
+ user = 'md5_user' , password = 'wrongpassword' )
191
184
192
185
async def test_auth_unsupported (self ):
193
186
pass
@@ -494,11 +487,9 @@ async def test_connection_ssl_to_no_ssl_server(self):
494
487
ssl_context .load_verify_locations (SSL_CA_CERT_FILE )
495
488
496
489
with self .assertRaisesRegex (ConnectionError , 'rejected SSL' ):
497
- await self .cluster . connect (
490
+ await self .connect (
498
491
host = 'localhost' ,
499
492
user = 'ssl_user' ,
500
- database = 'postgres' ,
501
- loop = self .loop ,
502
493
ssl = ssl_context )
503
494
504
495
async def test_connection_ssl_unix (self ):
@@ -507,15 +498,17 @@ async def test_connection_ssl_unix(self):
507
498
508
499
with self .assertRaisesRegex (asyncpg .InterfaceError ,
509
500
'can only be enabled for TCP addresses' ):
510
- await self .cluster . connect (
501
+ await self .connect (
511
502
host = '/tmp' ,
512
- loop = self .loop ,
513
503
ssl = ssl_context )
514
504
515
505
async def test_connection_implicit_host (self ):
516
- conn_spec = self .cluster . get_connection_spec ()
506
+ conn_spec = self .get_connection_spec ()
517
507
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 )
519
512
await con .close ()
520
513
521
514
@@ -576,11 +569,9 @@ async def test_ssl_connection_custom_context(self):
576
569
ssl_context = ssl .SSLContext (ssl .PROTOCOL_SSLv23 )
577
570
ssl_context .load_verify_locations (SSL_CA_CERT_FILE )
578
571
579
- con = await self .cluster . connect (
572
+ con = await self .connect (
580
573
host = 'localhost' ,
581
574
user = 'ssl_user' ,
582
- database = 'postgres' ,
583
- loop = self .loop ,
584
575
ssl = ssl_context )
585
576
586
577
try :
@@ -595,11 +586,9 @@ async def test_ssl_connection_custom_context(self):
595
586
596
587
async def test_ssl_connection_default_context (self ):
597
588
with self .assertRaisesRegex (ssl .SSLError , 'verify failed' ):
598
- await self .cluster . connect (
589
+ await self .connect (
599
590
host = 'localhost' ,
600
591
user = 'ssl_user' ,
601
- database = 'postgres' ,
602
- loop = self .loop ,
603
592
ssl = True )
604
593
605
594
async def test_ssl_connection_pool (self ):
0 commit comments