#NEWLINE# def test_match_hostname_mismatch( self ) : #NEWLINE# #INDENT# cert = { #NEWLINE# #INDENT# 'subjectAltName' : [ ( 'DNS' , 'foo' ) ] , #NEWLINE# #UNINDENT# } #NEWLINE# asserted_hostname = 'bar' #NEWLINE# try : #NEWLINE# #INDENT# with mock . patch ( 'urllib3.connection.log.error' ) as mock_log : #NEWLINE# #INDENT# _match_hostname ( cert , asserted_hostname ) #NEWLINE# #UNINDENT# #UNINDENT# except CertificateError as e : #NEWLINE# #INDENT# self . assertEqual ( str ( e ) , "hostname 'bar' doesn't match 'foo'" ) #NEWLINE# mock_log . assert_called_once_with ( 'Certificate did not match expected hostname: %s. Certificate: %s' , 'bar' , { #NEWLINE# #INDENT# 'subjectAltName' : [ ( 'DNS' , 'foo' ) ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( e . _peer_cert , cert )