diff options
author | Matthew Barber <quitesimplymatt@gmail.com> | 2021-09-01 09:47:19 +0100 |
---|---|---|
committer | Matthew <quitesimplymatt@gmail.com> | 2021-11-04 09:15:13 +0000 |
commit | 0ae911c9246a1366a60ed45ac0c28fd828498211 (patch) | |
tree | 5b2326bf5262230c76ea98d0a59512c449f3fc12 /numpy/tests/test_public_api.py | |
parent | f7a392d43286c39013d98b6bdeb93def645fa8ab (diff) | |
download | numpy-0ae911c9246a1366a60ed45ac0c28fd828498211.tar.gz |
Make test compatible with Python >=3.10
Diffstat (limited to 'numpy/tests/test_public_api.py')
-rw-r--r-- | numpy/tests/test_public_api.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index 81de66670..d8ebf32ea 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -465,12 +465,18 @@ def test_array_api_entry_point(): Entry point for Array API implementation can be found with importlib and returns the numpy.array_api namespace. """ - from numpy import array_api - eps = importlib.metadata.entry_points() - assert "array_api" in eps.keys() - xp_eps = eps["array_api"] + try: + xp_eps = eps.select(group="array_api") + except AttributeError: + # The select interface for entry_points was introduced in py3.10, + # 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 = importlib.import_module(ep.value) - assert xp is array_api + assert xp is numpy.array_api |