Skip to content

Commit 78b83f8

Browse files
committed
Fix test_tls_version in some environments
The kinds of errors raised on invalid TLS configuration seem to differ between platforms.
1 parent 4049167 commit 78b83f8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/test_connect.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,8 @@ async def test_executemany_uvloop_ssl_issue_700(self):
14381438
await con.close()
14391439

14401440
@unittest.skipIf(
1441-
sys.version_info < (3, 7), "Python < 3.7 doesn't have ssl.TLSVersion"
1441+
sys.version_info < (3, 7),
1442+
"Python < 3.7 doesn't have ssl.TLSVersion"
14421443
)
14431444
async def test_tls_version(self):
14441445
if self.cluster.get_pg_version() < (12, 0):
@@ -1455,12 +1456,15 @@ async def test_tls_version(self):
14551456
)
14561457
try:
14571458
self.loop.set_exception_handler(lambda *args: None)
1458-
with self.assertRaisesRegex(ssl.SSLError, 'protocol version'):
1459+
with self.assertRaisesRegex(
1460+
ssl.SSLError,
1461+
'(protocol version)|(handshake failure)',
1462+
):
14591463
await self.connect(
14601464
dsn='postgresql://ssl_user@localhost/postgres'
14611465
'?sslmode=require&ssl_min_protocol_version=TLSv1.3'
14621466
)
1463-
with self.assertRaises(ssl.SSLError):
1467+
with self.assertRaises((ssl.SSLError, ConnectionResetError)):
14641468
await self.connect(
14651469
dsn='postgresql://ssl_user@localhost/postgres'
14661470
'?sslmode=require'

0 commit comments

Comments
 (0)