def testSetDefaultSortFunc(self): store = gtk.ListStore(int) self.assertFalse(store.has_default_sort_func()) store.set_default_sort_func(lambda x: None) store.set_sort_column_id(0, gtk.SORT_ASCENDING) self.assertTrue(store.has_default_sort_func()) store.set_default_sort_func(None) self.assertFalse(store.has_default_sort_func())
def testTreeSelectionForeach(self): model = gtk.ListStore(str) treeview = gtk.TreeView(model) sel = treeview.get_selection() iter_ = model.append() model.set_value(iter_, 0, "foo") sel.select_path((0, )) list_ = [] sel.selected_foreach(lambda model, path, iter: list_.append(iter)) list_ = [model.get_value(iter_, 0) for iter_ in list_] self.assertEqual(list_, ["foo"])
def testInsert(self): store = gtk.ListStore(int) # Old way, with iters store.set_value(store.insert(0), 0, 2) self.assertEqual(len(store), 1) self.assertEqual(store[0][0], 2) # New way store.insert(0, (1,)) self.assertEqual(len(store), 2) self.assertEqual(store[0][0], 1) self.assertEqual(store[1][0], 2)
def testNegativeIndexSet(self): store = gtk.ListStore(int) for i in range(200): store.append((i,)) del store[-1] self.assert_(len(store) == 0)
def testNegativeIndexGet(self): store = gtk.ListStore(int) for i in range(200): store.append((i,)) self.assertEqual(store[-1][0], i)