21
21
from typing import TypeVar
22
22
23
23
import _pytest ._code
24
+ import numpy as np
24
25
from _pytest .outcomes import fail
25
26
26
27
@@ -438,7 +439,7 @@ def __eq__(self, actual) -> bool:
438
439
return all (self .__eq__ (a ) for a in asarray .flat )
439
440
440
441
# Short-circuit exact equality, except for bool
441
- if isinstance (self .expected , bool ) and not isinstance (actual , bool ):
442
+ if isinstance (self .expected , ( bool , np . bool_ )) and not isinstance (actual , ( bool , np . bool_ ) ):
442
443
return False
443
444
elif actual == self .expected :
444
445
return True
@@ -447,9 +448,9 @@ def __eq__(self, actual) -> bool:
447
448
# NB: we need Complex, rather than just Number, to ensure that __abs__,
448
449
# __sub__, and __float__ are defined. Also, consider bool to be
449
450
# nonnumeric, even though it has the required arithmetic.
450
- if isinstance (self .expected , bool ) or not (
451
- isinstance (self .expected , (Complex , Decimal ))
452
- and isinstance (actual , (Complex , Decimal ))
451
+ if isinstance (self .expected , ( bool , np . bool_ ) ) or not (
452
+ isinstance (self .expected , (Complex , Decimal ))
453
+ and isinstance (actual , (Complex , Decimal ))
453
454
):
454
455
return False
455
456
0 commit comments