def trigger_events(): with mvc.notifier(grandchild) as notify: notify({"data": 1}) with mvc.notifier(child) as notify: notify({"data": 2}) with mvc.notifier(parent) as notify: notify({"data": 3}) copy = calls[:] calls.clear() return copy
def test_notifier_context_manager(): calls = [] m = mvc.Model() @mvc.view(m) def viewer(m, events): calls.extend(events) with mvc.notifier(m) as notify: notify(data=1) assert calls == [] assert calls == [{"data": 1}] calls.clear() with mvc.notifier(m) as notify: notify(data=1) notify(data=2) assert calls == [{"data": 1}, {"data": 2}]