diff options
author | Matthew Barber <quitesimplymatt@gmail.com> | 2021-09-01 09:59:34 +0100 |
---|---|---|
committer | Matthew <quitesimplymatt@gmail.com> | 2021-11-04 09:15:13 +0000 |
commit | 2d601825d4bcb447911d063519c78bb5d5101dec (patch) | |
tree | cca42cf0251b39e22e62e0939419f722f7602c3e /numpy/tests/test_public_api.py | |
parent | 0ae911c9246a1366a60ed45ac0c28fd828498211 (diff) | |
download | numpy-2d601825d4bcb447911d063519c78bb5d5101dec.tar.gz |
Clearer test logic
Diffstat (limited to 'numpy/tests/test_public_api.py')
-rw-r--r-- | numpy/tests/test_public_api.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index d8ebf32ea..26402fa2a 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -473,10 +473,17 @@ def test_array_api_entry_point(): # deprecating its dict interface. We fallback to dict keys for finding # Array API entry points so that running this test in <=3.9 will # still work - see https://github.com/numpy/numpy/pull/19800. - assert "array_api" in eps.keys() - xp_eps = eps["array_api"] - assert len(xp_eps) > 0 - assert "numpy" in (ep.name for ep in xp_eps) - ep = next(ep for ep in xp_eps if ep.name == "numpy") + xp_eps = eps.get("array_api", []) + assert len(xp_eps) > 0, "No entry points for 'array_api' found" + + try: + ep = next(ep for ep in xp_eps if ep.name == "numpy") + except StopIteration: + raise AssertionError("'numpy' not in array_api entry points") from None + xp = importlib.import_module(ep.value) - assert xp is numpy.array_api + msg = ( + f"numpy entry point value '{ep.value}' " + "does not point to our Array API implementation" + ) + assert xp is numpy.array_api, msg |