From 12f1c01ab33f55b752ae49c01a75bf9809ec3ef7 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 1 Aug 2022 14:46:45 -0500 Subject: [PATCH 1/4] Test all Codec classes (see #347) --- numcodecs/tests/test_registry.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/numcodecs/tests/test_registry.py b/numcodecs/tests/test_registry.py index c6582cb3..2d0a15f2 100644 --- a/numcodecs/tests/test_registry.py +++ b/numcodecs/tests/test_registry.py @@ -1,6 +1,9 @@ import pytest +import importlib +import inspect +import numcodecs from numcodecs.registry import get_codec @@ -15,3 +18,24 @@ def test_get_codec_argument(): before = dict(arg) get_codec(arg) assert before == arg + + +def test_all_classes_registered(): + """ + find all Codec subclasses in this repository and check that they + have been registered. + + see #346 for more info + """ + missing = set() + for name, submod in inspect.getmembers(numcodecs, inspect.ismodule): + for name, obj in inspect.getmembers(submod): + if inspect.isclass(obj): + if issubclass(obj, numcodecs.abc.Codec): + if obj.codec_id not in numcodecs.registry.codec_registry: + missing.add(obj.codec_id) + + # remove `None`` + missing.remove(None) + if missing: + raise Exception(f"these codecs are missing: {missing}") From 64f68b77ca56585d8c05d02641497df4b8c8a394 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 1 Aug 2022 14:59:02 -0500 Subject: [PATCH 2/4] Add release notes --- docs/release.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/release.rst b/docs/release.rst index 949ffacf..aa10af4c 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -6,10 +6,16 @@ Release notes # to document your changes. On releases it will be # re-indented so that it does not show up in the notes. - .. _unreleased: +.. _unreleased: - Unreleased - ---------- +Unreleased +---------- + +Maintenance +~~~~~~~~~~~ + +* Add tests for all registry classes. + By :user:`Josh Moore `, :issue:`349`. .. _release_0.10.2: From a0f45c60664a2b99e3d335a0132b53a6c3fba190 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 1 Aug 2022 14:59:31 -0500 Subject: [PATCH 3/4] Fix indents --- numcodecs/tests/test_registry.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/numcodecs/tests/test_registry.py b/numcodecs/tests/test_registry.py index 2d0a15f2..271c2896 100644 --- a/numcodecs/tests/test_registry.py +++ b/numcodecs/tests/test_registry.py @@ -29,11 +29,11 @@ def test_all_classes_registered(): """ missing = set() for name, submod in inspect.getmembers(numcodecs, inspect.ismodule): - for name, obj in inspect.getmembers(submod): - if inspect.isclass(obj): - if issubclass(obj, numcodecs.abc.Codec): - if obj.codec_id not in numcodecs.registry.codec_registry: - missing.add(obj.codec_id) + for name, obj in inspect.getmembers(submod): + if inspect.isclass(obj): + if issubclass(obj, numcodecs.abc.Codec): + if obj.codec_id not in numcodecs.registry.codec_registry: + missing.add(obj.codec_id) # remove `None`` missing.remove(None) From 97a568b2f453ea1b2a44572277ff6b15a3623064 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 1 Aug 2022 15:20:41 -0500 Subject: [PATCH 4/4] Remove importlib --- numcodecs/tests/test_registry.py | 1 - 1 file changed, 1 deletion(-) diff --git a/numcodecs/tests/test_registry.py b/numcodecs/tests/test_registry.py index 271c2896..a9e6b233 100644 --- a/numcodecs/tests/test_registry.py +++ b/numcodecs/tests/test_registry.py @@ -1,6 +1,5 @@ import pytest -import importlib import inspect import numcodecs