commit:     cd8fbdb5dc60d6b790dea42de3ac34d132cbb2c9
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Sat Jan 10 11:55:28 2026 +0000
Commit:     Brian Harring <ferringb <AT> gmail <DOT> com>
CommitDate: Sat Jan 10 11:55:28 2026 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=cd8fbdb5

Make tests NamespaceCollector seperate from code_quality

It's a general tool, and centralizing this outside of 'code quality'
makes sense for some things that pkgcore and pkgcheck do w/ registries.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/snakeoil/test/code_quality.py | 31 +------------------------------
 src/snakeoil/test/util.py         | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/src/snakeoil/test/code_quality.py 
b/src/snakeoil/test/code_quality.py
index 7b5a872..e3fffcb 100644
--- a/src/snakeoil/test/code_quality.py
+++ b/src/snakeoil/test/code_quality.py
@@ -12,37 +12,8 @@ from snakeoil.klass import (
     get_slots_of,
     get_subclasses_of,
 )
-from snakeoil.python_namespaces import get_submodules_of
-from snakeoil.test import AbstractTest
 
-T = typing.TypeVar("T")
-
-
-class NamespaceCollector(AbstractTest):
-    namespaces: tuple[str] = abstractclassvar(tuple[str])
-    namespace_ignores: tuple[str, ...] = ()
-
-    strict_configurable_tests: typing.ClassVar[tuple[str, ...]] = ()
-    strict: typing.ClassVar[typing.Literal[True] | tuple[str, ...]] = ()
-
-    def __init_subclass__(cls, **kwargs) -> None:
-        if not inspect.isabstract(cls):
-            targets = cls.strict_configurable_tests
-            strict = targets if cls.strict is True else cls.strict
-            for test_name in cls.strict_configurable_tests:
-                if test_name not in strict:
-                    setattr(cls, test_name, pytest.mark.xfail(getattr(cls, 
test_name)))
-
-        return super().__init_subclass__(**kwargs)
-
-    @classmethod
-    def collect_modules(cls) -> typing.Iterable[ModuleType]:
-        for namespace in cls.namespaces:
-            yield from get_submodules_of(
-                namespace,
-                dont_import=cls.namespace_ignores,
-                include_root=True,
-            )
+from .util import NamespaceCollector
 
 
 class Slots(NamespaceCollector, still_abstract=True):

diff --git a/src/snakeoil/test/util.py b/src/snakeoil/test/util.py
new file mode 100644
index 0000000..97c8d3c
--- /dev/null
+++ b/src/snakeoil/test/util.py
@@ -0,0 +1,37 @@
+__all__ = ("NamespaceCollector",)
+import inspect
+import types
+import typing
+
+import pytest
+
+from snakeoil import klass
+from snakeoil.python_namespaces import get_submodules_of
+from snakeoil.test import AbstractTest
+
+
+class NamespaceCollector(AbstractTest):
+    namespaces: tuple[str] = klass.abstractclassvar(tuple[str])
+    namespace_ignores: tuple[str, ...] = ()
+
+    strict_configurable_tests: typing.ClassVar[tuple[str, ...]] = ()
+    strict: typing.ClassVar[typing.Literal[True] | tuple[str, ...]] = ()
+
+    def __init_subclass__(cls, **kwargs) -> None:
+        if not inspect.isabstract(cls):
+            targets = cls.strict_configurable_tests
+            strict = targets if cls.strict is True else cls.strict
+            for test_name in cls.strict_configurable_tests:
+                if test_name not in strict:
+                    setattr(cls, test_name, pytest.mark.xfail(getattr(cls, 
test_name)))
+
+        return super().__init_subclass__(**kwargs)
+
+    @classmethod
+    def collect_modules(cls) -> typing.Iterable[types.ModuleType]:
+        for namespace in cls.namespaces:
+            yield from get_submodules_of(
+                namespace,
+                dont_import=cls.namespace_ignores,
+                include_root=True,
+            )

Reply via email to