def empty_collection(self, item_cls, attached, attach_items): list_ = SyncedList(validation=_PartialIsInstance(item_cls), attach_members=attach_items) if attached: self._synced_list = [] list_._sync(DummySimulation(), self._synced_list) return list_
def test_synced(self): test_list = SyncedList(lambda x: x) assert not test_list._synced test_list._sync(None, []) assert test_list._synced test_list._unsync() assert not test_list._synced
def test_attach(): triggered_op = DummyTriggeredOp(trigger=1) sim = DummySimulation() slist = SyncedList(lambda x: isinstance(x, DummyTriggeredOp), lambda x: (x._cpp_obj, x.trigger)) slist.append(triggered_op) triggered_op._cpp_obj = DummyCppObj() slist._sync(sim, sim._cpp_sys.dummy_list) assert len(sim._cpp_sys.dummy_list) == 1 assert len(sim._cpp_sys.dummy_list[0]) == 2 assert triggered_op._cpp_obj == sim._cpp_sys.dummy_list[0][0] assert triggered_op.trigger == sim._cpp_sys.dummy_list[0][1]