#NEWLINE# @ unittest . skip ( 'mtestfile not supported' ) #NEWLINE# @ requires_IEEE_754 #NEWLINE# def test_mtestfile( self ) : #NEWLINE# #INDENT# fail_fmt = '{}:{}({!r}): expected {!r}, got {!r}' #NEWLINE# failures = [ ] #NEWLINE# for ( id , fn , arg , expected , flags ) in parse_mtestfile ( math_testcases ) : #NEWLINE# #INDENT# func = getattr ( math , fn ) #NEWLINE# if ( ( 'invalid' in flags ) or ( 'divide-by-zero' in flags ) ) : #NEWLINE# #INDENT# expected = 'ValueError' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'overflow' in flags ) : #NEWLINE# #INDENT# expected = 'OverflowError' #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# got = func ( arg ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# got = 'ValueError' #NEWLINE# #UNINDENT# except OverflowError : #NEWLINE# #INDENT# got = 'OverflowError' #NEWLINE# #UNINDENT# accuracy_failure = None #NEWLINE# if ( isinstance ( got , float ) and isinstance ( expected , float ) ) : #NEWLINE# #INDENT# if ( math . isnan ( expected ) and math . isnan ( got ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( ( not math . isnan ( expected ) ) and ( not math . isnan ( got ) ) ) : #NEWLINE# #INDENT# if ( fn == 'lgamma' ) : #NEWLINE# #INDENT# accuracy_failure = acc_check ( expected , got , rel_err = 5e-15 , abs_err = 5e-15 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( fn == 'erfc' ) : #NEWLINE# #INDENT# accuracy_failure = ulps_check ( expected , got , 2000 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# accuracy_failure = ulps_check ( expected , got , 20 ) #NEWLINE# #UNINDENT# #UNINDENT# if ( accuracy_failure is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( isinstance ( got , str ) and isinstance ( expected , str ) ) : #NEWLINE# #INDENT# if ( got == expected ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# fail_msg = fail_fmt . format ( id , fn , arg , expected , got ) #NEWLINE# if ( accuracy_failure is not None ) : #NEWLINE# #INDENT# fail_msg += ' ({})' . format ( accuracy_failure ) #NEWLINE# #UNINDENT# failures . append ( fail_msg ) #NEWLINE# #UNINDENT# if failures : #NEWLINE# #INDENT# self . fail ( ( 'Failures in test_mtestfile:\n  ' + '\n  ' . join ( failures ) ) )