aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2022-09-26 13:09:59 +0300
committerArthur Zamarin <arthurzam@gentoo.org>2022-09-26 13:09:59 +0300
commit5edd0d6ea258aab0cb8d4c72896c8822eea7b518 (patch)
treefcd835a01293088518401f937512ccde9a7f771d
parentdescriptors: remove unused `classproperty` (diff)
downloadsnakeoil-5edd0d6ea258aab0cb8d4c72896c8822eea7b518.tar.gz
snakeoil-5edd0d6ea258aab0cb8d4c72896c8822eea7b518.tar.bz2
snakeoil-5edd0d6ea258aab0cb8d4c72896c8822eea7b518.zip
move `DemandLoadTargets` to tests
Used only in tests, which test `mixins.PythonNamespaceWalker`, meaning I can't just remove it. Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--src/snakeoil/test/demandload.py30
-rw-r--r--tests/test_demandload_usage.py32
2 files changed, 29 insertions, 33 deletions
diff --git a/src/snakeoil/test/demandload.py b/src/snakeoil/test/demandload.py
deleted file mode 100644
index 9ce8f5de..00000000
--- a/src/snakeoil/test/demandload.py
+++ /dev/null
@@ -1,30 +0,0 @@
-from . import mixins
-
-
-class DemandLoadTargets(mixins.PythonNamespaceWalker):
-
- target_namespace = 'snakeoil'
- ignore_all_import_failures = False
-
- def setup_method(self, method):
- self._failures = []
-
- def teardown_method(self, method):
- msg = "\n".join(sorted(f"{target}: error {e}" for target, e in self._failures))
- assert not self._failures, "bad demandload targets:\n" + msg
-
- def test_demandload_targets(self):
- for x in self.walk_namespace(
- self.target_namespace,
- ignore_failed_imports=self.ignore_all_import_failures):
- self.check_space(x)
-
- def check_space(self, mod):
- for attr in dir(mod):
- try:
- obj = getattr(mod, attr)
- # force __getattribute__ to fire
- getattr(obj, "__class__", None)
- except ImportError as ie:
- # hit one.
- self._failures.append((f"{mod.__name__}: target {attr}", ie))
diff --git a/tests/test_demandload_usage.py b/tests/test_demandload_usage.py
index bf0d188c..79ccfe03 100644
--- a/tests/test_demandload_usage.py
+++ b/tests/test_demandload_usage.py
@@ -1,5 +1,31 @@
-from snakeoil.test.demandload import DemandLoadTargets
+import pytest
+from snakeoil.test import mixins
-class TestDemandLoadTargets(DemandLoadTargets):
- pass
+class TestDemandLoadTargets(mixins.PythonNamespaceWalker):
+
+ target_namespace = 'snakeoil'
+ ignore_all_import_failures = False
+
+ @pytest.fixture(autouse=True)
+ def _setup(self):
+ self._failures = []
+ yield
+ msg = "\n".join(sorted(f"{target}: error {e}" for target, e in self._failures))
+ assert not self._failures, "bad demandload targets:\n" + msg
+
+ def test_demandload_targets(self):
+ for x in self.walk_namespace(
+ self.target_namespace,
+ ignore_failed_imports=self.ignore_all_import_failures):
+ self.check_space(x)
+
+ def check_space(self, mod):
+ for attr in dir(mod):
+ try:
+ obj = getattr(mod, attr)
+ # force __getattribute__ to fire
+ getattr(obj, "__class__", None)
+ except ImportError as ie:
+ # hit one.
+ self._failures.append((f"{mod.__name__}: target {attr}", ie))