summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-03-24 11:49:33 -0700
committerSebastian Berg <sebastian@sipsolutions.net>2022-03-24 12:04:51 -0700
commite8e2ea0e020c0f0715f6b233543604f711533628 (patch)
tree3a79eee637653b8e13db4a657b5aed369e134bf4 /numpy
parent6c4b452b8a00a70b54cf3a8b127752179e938dd1 (diff)
downloadnumpy-e8e2ea0e020c0f0715f6b233543604f711533628.tar.gz
TST: Add test for `__array_priority__` raising a bad error
As the TODO note states, this should probably just raise the error, but for now, lets cover the code path and make sure it doesn't do worse at least.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_multiarray.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 64b173051..8c7f00cb4 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -3694,12 +3694,18 @@ class TestBinop:
check(make_obj(np.ndarray, array_ufunc=None), True, False, False,
check_scalar=False)
- def test_ufunc_binop_bad_array_priority(self):
+ @pytest.mark.parametrize("priority", [None, "runtime error"])
+ def test_ufunc_binop_bad_array_priority(self, priority):
# Mainly checks that this does not crash. The second array has a lower
# priority than -1 ("error value"). If the __radd__ actually exists,
# bad things can happen (I think via the scalar paths).
- class BadPriority():
- __array_priority__ = None
+ # In principle both of these can probably just be errors in the future.
+ class BadPriority:
+ @property
+ def __array_priority__(self):
+ if priority == "runtime error":
+ raise RuntimeError("RuntimeError in __array_priority__!")
+ return priority
def __radd__(self, other):
return "result"