diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-01-20 17:57:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 17:57:37 -0700 |
commit | 72be9ca10b5391fc036c4cd61830e168712b51ea (patch) | |
tree | 6d3bf30490c291982a2eabeabb487fbdfd7e0335 /numpy/core/tests | |
parent | f10da39336097fca740dd1c407939eb9c6c4ca3e (diff) | |
parent | a054ffd20ba2cd865a53e6ab149ae7d24acc97d9 (diff) | |
download | numpy-72be9ca10b5391fc036c4cd61830e168712b51ea.tar.gz |
Merge pull request #18197 from seberg/array-protocol-errors
BUG: Keep ignoring most errors during array-protocol lookup
Diffstat (limited to 'numpy/core/tests')
-rw-r--r-- | numpy/core/tests/test_array_coercion.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/numpy/core/tests/test_array_coercion.py b/numpy/core/tests/test_array_coercion.py index 08b32dfcc..8f709dbe1 100644 --- a/numpy/core/tests/test_array_coercion.py +++ b/numpy/core/tests/test_array_coercion.py @@ -702,17 +702,19 @@ class TestArrayLikes: @pytest.mark.parametrize("attribute", ["__array_interface__", "__array__", "__array_struct__"]) - def test_bad_array_like_attributes(self, attribute): - # Check that errors during attribute retrieval are raised unless - # they are Attribute errors. + @pytest.mark.parametrize("error", [RecursionError, MemoryError]) + def test_bad_array_like_attributes(self, attribute, error): + # RecursionError and MemoryError are considered fatal. All errors + # (except AttributeError) should probably be raised in the future, + # but shapely made use of it, so it will require a deprecation. class BadInterface: def __getattr__(self, attr): if attr == attribute: - raise RuntimeError + raise error super().__getattr__(attr) - with pytest.raises(RuntimeError): + with pytest.raises(error): np.array(BadInterface()) @pytest.mark.parametrize("error", [RecursionError, MemoryError]) |