Two stages: register as a modifier (it was never installed), test that every install() is provided
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tw9fjWwkXVabCNSQ53xaW1
This commit is contained in:
@@ -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}"
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user