def test_iter_append_many_empty(self): m = ObjectStore() for x in m.iter_append_many([]): pass for x in m.iter_append_many(iter([])): pass
def test_signal_count(self): m = ObjectStore() def handler(model, path, iter_, result): result[0] += 1 inserted = [0] m.connect("row-inserted", handler, inserted) changed = [0] m.connect("row-changed", handler, changed) m.append([1]) m.prepend([8]) m.insert(0, [1]) m.insert_before(None, [1]) m.insert_after(None, [1]) m.insert_many(0, [1, 2, 3]) m.append_many([1, 2, 3]) list(m.iter_append_many([1, 2, 3])) list(m.iter_append_many(range(3))) self.assertEqual(changed[0], 0) self.assertEqual(inserted[0], len(m))
def test_signal_count(self): m = ObjectStore() def handler(model, path, iter_, result): result[0] += 1 inserted = [0] m.connect("row-inserted", handler, inserted) changed = [0] m.connect("row-changed", handler, changed) m.append([1]) m.prepend([8]) m.insert(0, [1]) m.insert_before(None, [1]) m.insert_after(None, [1]) m.insert_many(0, [1, 2, 3]) m.append_many([1, 2, 3]) list(m.iter_append_many([1, 2, 3])) list(m.iter_append_many(xrange(3))) self.assertEqual(changed[0], 0) self.assertEqual(inserted[0], len(m))
def test_iter_append_many_iterable_object(self): objects = [object() for i in xrange(10)] m = ObjectStore() for x in m.iter_append_many((i for i in objects)): pass self.failUnlessEqual([r[0] for r in m], objects)
def test_iter_append_many_iterable_int(self): m = ObjectStore() for x in m.iter_append_many((i for i in xrange(10))): pass self.failUnlessEqual([r[0] for r in m], range(10))
def test_iter_append_many(self): m = ObjectStore() iters = list(m.iter_append_many(range(10))) self.failUnlessEqual([r[0] for r in m], range(10)) values = [m.get_value(i) for i in iters] self.failUnlessEqual(values, range(10))