Allow decorating multiple methods per module #47

This commit is contained in:
Kivi Kaitaniemi
2026-02-07 20:52:32 +02:00
parent 7aa063f6b9
commit 37745d1730
9 changed files with 73 additions and 32 deletions
+17 -3
View File
@@ -1,5 +1,5 @@
from decman.core.module import Module
from decman.plugins import run_method_with_attribute
from decman.plugins import run_methods_with_attribute
def mark(attr):
@@ -14,7 +14,21 @@ def test_runs_marked_method_and_returns_value():
return 123
m = M("m")
assert run_method_with_attribute(m, "__flag__") == 123
assert run_methods_with_attribute(m, "__flag__") == [123]
def test_runs_marked_methods_and_returns_value():
class M(Module):
@mark
def foo(self):
return 123
@mark
def bar(self):
return 321
m = M("m")
assert run_methods_with_attribute(m, "__flag__") == [321, 123]
def test_returns_none_if_no_method_has_attribute():
@@ -23,4 +37,4 @@ def test_returns_none_if_no_method_has_attribute():
return 1
m = M("m")
assert run_method_with_attribute(m, "__flag__") is None
assert run_methods_with_attribute(m, "__flag__") == []