Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from typing import TYPE_CHECKING
from typing import TypeVar

import numpy as np

import _pytest._code
from _pytest.outcomes import fail

Expand Down Expand Up @@ -438,7 +440,9 @@ def __eq__(self, actual) -> bool:
return all(self.__eq__(a) for a in asarray.flat)

# Short-circuit exact equality, except for bool
if isinstance(self.expected, bool) and not isinstance(actual, bool):
if isinstance(self.expected, (bool, np.bool_)) and not isinstance(
actual, (bool, np.bool_)
):
return False
elif actual == self.expected:
return True
Expand All @@ -447,7 +451,7 @@ def __eq__(self, actual) -> bool:
# NB: we need Complex, rather than just Number, to ensure that __abs__,
# __sub__, and __float__ are defined. Also, consider bool to be
# nonnumeric, even though it has the required arithmetic.
if isinstance(self.expected, bool) or not (
if isinstance(self.expected, (bool, np.bool_)) or not (
isinstance(self.expected, (Complex, Decimal))
and isinstance(actual, (Complex, Decimal))
):
Expand Down