@@ -507,7 +507,8 @@ def test_complex(self):
507
507
self ._test_not_equal (x , z )
508
508
509
509
def test_error_message (self ):
510
- """Check the message is formatted correctly for the decimal value"""
510
+ """Check the message is formatted correctly for the decimal value.
511
+ Also check the message when input includes inf or nan (gh12200)"""
511
512
x = np .array ([1.00000000001 , 2.00000000002 , 3.00003 ])
512
513
y = np .array ([1.00000000002 , 2.00000000003 , 3.00004 ])
513
514
@@ -531,6 +532,19 @@ def test_error_message(self):
531
532
# remove anything that's not the array string
532
533
assert_equal (str (e ).split ('%)\n ' )[1 ], b )
533
534
535
+ # Check the error message when input includes inf or nan
536
+ x = np .array ([np .inf , 0 ])
537
+ y = np .array ([np .inf , 1 ])
538
+ try :
539
+ self ._assert_func (x , y )
540
+ except AssertionError as e :
541
+ msgs = str (e ).split ('\n ' )
542
+ # assert error percentage is 50%
543
+ assert_equal (msgs [3 ], '(mismatch 50.0%)' )
544
+ # assert output array contains inf
545
+ assert_equal (msgs [4 ], ' x: array([inf, 0.])' )
546
+ assert_equal (msgs [5 ], ' y: array([inf, 1.])' )
547
+
534
548
def test_subclass_that_cannot_be_bool (self ):
535
549
# While we cannot guarantee testing functions will always work for
536
550
# subclasses, the tests should ideally rely only on subclasses having
@@ -1115,7 +1129,7 @@ def test_simple(self):
1115
1129
1116
1130
assert_raises (AssertionError ,
1117
1131
lambda : assert_string_equal ("foo" , "hello" ))
1118
-
1132
+
1119
1133
def test_regex (self ):
1120
1134
assert_string_equal ("a+*b" , "a+*b" )
1121
1135
0 commit comments