@@ -1725,7 +1725,7 @@ def test_bad_server_hostname(self):
17251725 with self .assertWarns (DeprecationWarning ):
17261726 ctx .wrap_bio (ssl .MemoryBIO (), ssl .MemoryBIO (),
17271727 server_hostname = None )
1728- with self .assertRaises (DeprecationWarning ):
1728+ with self .assertRaises (ValueError ):
17291729 ctx .wrap_bio (ssl .MemoryBIO (), ssl .MemoryBIO (),
17301730 server_hostname = "" )
17311731 with self .assertRaises (ValueError ):
@@ -1817,30 +1817,32 @@ def test_check_hostname_requires_server_hostname(self):
18171817 client_context , _ , hostname = testing_context ()
18181818 self .assertTrue (client_context .check_hostname )
18191819
1820- for server_hostname in ( None , "" ):
1821- with self .subTest ( server_hostname = server_hostname ):
1822- with self . assertWarnsRegex (
1823- DeprecationWarning ,
1824- "check_hostname requires server_hostname" ):
1825- client_context . wrap_bio ( ssl . MemoryBIO (), ssl . MemoryBIO (),
1826- server_hostname = server_hostname )
1827- # The sibling constructor refuses the very same call .
1828- with socket .socket () as sock :
1829- with self .assertWarnsRegex (
1830- DeprecationWarning ,
1831- "check_hostname requires server_hostname" ):
1832- client_context .wrap_socket (
1833- sock , server_hostname = server_hostname )
1820+ server_hostname = None
1821+ with self .assertWarnsRegex (
1822+ DeprecationWarning ,
1823+ "check_hostname requires server_hostname" ):
1824+ client_context . wrap_bio ( ssl . MemoryBIO (), ssl . MemoryBIO (),
1825+ server_hostname = server_hostname )
1826+ # The sibling constructor refuses the very same call, but with
1827+ # a ValueError instead of DeprecationWarning .
1828+ with socket .socket () as sock :
1829+ with self .assertRaisesRegex (
1830+ ValueError ,
1831+ "check_hostname requires server_hostname" ):
1832+ client_context .wrap_socket (
1833+ sock , server_hostname = server_hostname )
18341834
18351835 # A name was all that was missing.
1836- client_context .wrap_bio (ssl .MemoryBIO (), ssl .MemoryBIO (),
1837- server_hostname = hostname )
1836+ with warnings_helper .check_no_warnings (self ):
1837+ client_context .wrap_bio (ssl .MemoryBIO (), ssl .MemoryBIO (),
1838+ server_hostname = hostname )
18381839
18391840 # Asking for no hostname check remains a way to say so explicitly.
18401841 context = ssl .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
18411842 context .check_hostname = False
18421843 self .assertFalse (context .check_hostname )
1843- context .wrap_bio (ssl .MemoryBIO (), ssl .MemoryBIO ())
1844+ with warnings_helper .check_no_warnings (self ):
1845+ context .wrap_bio (ssl .MemoryBIO (), ssl .MemoryBIO ())
18441846
18451847 def test_server_side_bad_params (self ):
18461848 # A server neither sends a hostname nor resumes a client's session,
0 commit comments