def test_popitem_nocallback(self): ld = LabelledDict(label='all_objects', key_attr='prop1') obj1 = MyTestClass('a', 'b') ld.add(obj1) ret = ld.popitem() self.assertEqual(ret, ('a', obj1)) self.assertEqual(ld, dict())
def test_popitem_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.popitem() self.assertEqual(ret, ('a', obj1)) self.assertEqual(self.signal, obj1) self.assertEqual(ld, dict())