diff --git a/core/tests/test_modifiers_provided.py b/core/tests/test_modifiers_provided.py new file mode 100644 index 00000000..9844ce82 --- /dev/null +++ b/core/tests/test_modifiers_provided.py @@ -0,0 +1,23 @@ +"""A module with an `install(patcher, values, key)` that never lists it in PROVIDES is never installed (the +Load Modifiers node only calls what is provided), and its own tests still pass because they call it directly.""" + +import importlib +import pkgutil + +import modules + + +def test_every_modifier_install_is_provided(): + missing = [] + for info in pkgutil.walk_packages(modules.__path__, "modules."): + if not info.ispkg or info.name.rsplit(".", 1)[-1] in ("tests", "_core"): + continue + try: + mod = importlib.import_module(info.name) + except Exception: # noqa: BLE001 -- a missing dependency is not this test's business + continue + fn = getattr(mod, "install", None) + if fn is not None and getattr(mod, "__file__", "").endswith("__init__.py") and hasattr(mod, "ID"): + if getattr(mod, "PROVIDES", {}).get("modifier") is not fn: + missing.append(info.name) + assert not missing, f"install() not provided as a modifier: {missing}" diff --git a/modules/sampling/two_stage/__init__.py b/modules/sampling/two_stage/__init__.py index 5df64895..b7d0dfad 100644 --- a/modules/sampling/two_stage/__init__.py +++ b/modules/sampling/two_stage/__init__.py @@ -52,3 +52,6 @@ def install(patcher, values, key): size, steps = float(values.get("size", 0.7)), int(values.get("steps", 2)) patcher.add_wrapper_with_key(WrappersMP.OUTER_SAMPLE, key, make_wrapper(size, steps)) return f"first {steps} step(s) at {size:.0%} of the size" + + +PROVIDES = {"modifier": install}