Skip to content

Commit 90e1534

Browse files
committed
test(validation): scope list_mod_check like GenericObject._verify_slot
The framework-tier harness in test_included_stateful.py set obj.list_mod_check = True for the whole detached-ask block and reset it to a literal False afterward, instead of scoping it to just the included() call and restoring the ORIGINAL value the way GenericObject._verify_slot does. Mirror the real method's finally discipline. Also make tests.matrix_support.allows_other_modifiers delegate to GenericObject._allows_other_modifiers instead of re-implementing the attribute-vs-method split, the same way hdc_id delegates to obj.hdc_id(). No engine logic changes; 77/77 focused tests still pass.
1 parent 41f2d3a commit 90e1534

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

tests/matrix_support.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ def hdc_id(obj) -> str:
131131

132132

133133
def allows_other_modifiers(obj) -> bool:
134-
"""``GenericObject.allows_other_modifiers`` is a bool attribute on the
135-
base class but a METHOD override on a handful of subclasses (martial
136-
arts elements, ``Disadvantage``) -- call it if callable, else read it."""
137-
val = obj.allows_other_modifiers
138-
return val() if callable(val) else val
134+
"""Delegates to the library's own ``GenericObject._allows_other_modifiers``
135+
(base.py) -- that is the one accessor for the attribute-vs-method split
136+
(a bool attribute on the base class, a METHOD override on a handful of
137+
subclasses: martial arts elements, ``Disadvantage``), same as ``hdc_id``."""
138+
return GenericObject._allows_other_modifiers(obj)
139139

140140

141141
@lru_cache(maxsize=1)

tests/test_included_stateful.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,20 @@ def _ask(cell: dict, index: dict) -> tuple[bool, str]:
6565
with_siblings = list(orig_assigned) + [m for m in missing if m is not mod]
6666

6767
orig_obj_parent = obj.parent
68+
orig_check = obj.list_mod_check
6869
obj.assigned_modifiers = with_siblings
6970
obj.parent = None
7071
if compound_id:
7172
compound.parent = None
72-
obj.list_mod_check = True
7373
try:
7474
if not allows_other_modifiers(obj):
7575
return False, f"{obj.alias} does not allow modifiers with its current configuration."
76-
reason = mod.included(obj) or ""
76+
obj.list_mod_check = True # GenericObject._verify_slot: around the ask only
77+
try:
78+
reason = mod.included(obj) or ""
79+
finally:
80+
obj.list_mod_check = orig_check
7781
finally:
78-
obj.list_mod_check = False
7982
obj.assigned_modifiers = orig_assigned
8083
obj.parent = orig_obj_parent
8184
if compound_id:

0 commit comments

Comments
 (0)