def test_pop_nocallback(self): ld = LabelledDict(label='all_objects', key_attr='prop1') obj1 = MyTestClass('a', 'b') ld.add(obj1) ret = ld.pop('a') self.assertEqual(ret, obj1) self.assertEqual(ld, dict())
def test_pop_callback(self): self.signal = None def func(v): self.signal = v ld = LabelledDict(label='all_objects', key_attr='prop1', remove_callable=func) obj1 = MyTestClass('a', 'b') ld.add(obj1) ret = ld.pop('a') self.assertEqual(ret, obj1) self.assertEqual(self.signal, obj1) self.assertEqual(ld, dict())