Skip to content

Commit 479a82f

Browse files
committed
Attempt to fix spurious failures of test_auth_reject on Windows
1 parent b8eac82 commit 479a82f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: tests/test_connect.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,21 @@ async def test_auth_reject(self):
109109
with self.assertRaisesRegex(
110110
asyncpg.InvalidAuthorizationSpecificationError,
111111
'pg_hba.conf rejects connection'):
112-
await self.cluster.connect(
113-
user='reject_user', database='postgres', loop=self.loop)
112+
for tried in range(3):
113+
try:
114+
await self.cluster.connect(
115+
user='reject_user', database='postgres',
116+
loop=self.loop)
117+
except asyncpg.ConnectionDoesNotExistError:
118+
if _system == 'Windows':
119+
# On Windows the server sometimes just closes
120+
# the connection sooner than we receive the
121+
# actual error.
122+
continue
123+
else:
124+
raise
125+
else:
126+
break
114127

115128
async def test_auth_password_cleartext(self):
116129
conn = await self.cluster.connect(

0 commit comments

Comments
 (0)