diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2023-05-16 09:28:34 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-16 09:28:34 -0600 |
commit | 6a4abb065afa5cd9967b92476cd8a245edf3dfcd (patch) | |
tree | 7a16f842650373e869fccdf2299259bd27a989cd /numpy/core/tests | |
parent | a4a951d2ba256f6a391ae6dca30bee2bb491a59f (diff) | |
parent | 8b7f69ceae5cd99592f79121a1bd7b014af4833c (diff) | |
download | numpy-6a4abb065afa5cd9967b92476cd8a245edf3dfcd.tar.gz |
Merge pull request #23659 from seberg/issue-23029
ENH: Restore TypeError cleanup in array function dispatching
Diffstat (limited to 'numpy/core/tests')
-rw-r--r-- | numpy/core/tests/test_overrides.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/numpy/core/tests/test_overrides.py b/numpy/core/tests/test_overrides.py index 25f551f6f..5924358ea 100644 --- a/numpy/core/tests/test_overrides.py +++ b/numpy/core/tests/test_overrides.py @@ -359,6 +359,17 @@ class TestArrayFunctionImplementation: TypeError, "no implementation found for 'my.func'"): func(MyArray()) + @pytest.mark.parametrize("name", ["concatenate", "mean", "asarray"]) + def test_signature_error_message_simple(self, name): + func = getattr(np, name) + try: + # all of these functions need an argument: + func() + except TypeError as e: + exc = e + + assert exc.args[0].startswith(f"{name}()") + def test_signature_error_message(self): # The lambda function will be named "<lambda>", but the TypeError # should show the name as "func" @@ -370,7 +381,7 @@ class TestArrayFunctionImplementation: pass try: - func(bad_arg=3) + func._implementation(bad_arg=3) except TypeError as e: expected_exception = e @@ -378,6 +389,12 @@ class TestArrayFunctionImplementation: func(bad_arg=3) raise AssertionError("must fail") except TypeError as exc: + if exc.args[0].startswith("_dispatcher"): + # We replace the qualname currently, but it used `__name__` + # (relevant functions have the same name and qualname anyway) + pytest.skip("Python version is not using __qualname__ for " + "TypeError formatting.") + assert exc.args == expected_exception.args @pytest.mark.parametrize("value", [234, "this func is not replaced"]) |