summaryrefslogtreecommitdiff
path: root/tests/test_liststore.py
blob: da53a07e5b6b2423f29099aa03de14341d5e6f48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest

from common import gtk

class ListStoreTest(unittest.TestCase):
    def testConstructor(self):
        self.assertRaises(TypeError, gtk.ListStore)

    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)

    # TreeSortable, but...

    def testSetDefaultSortFunc(self):
        store = gtk.ListStore(int)
        self.failIf(store.has_default_sort_func())
        store.set_default_sort_func(lambda x: None)
        store.set_sort_column_id(0, gtk.SORT_ASCENDING)

        self.failUnless(store.has_default_sort_func())
        store.set_default_sort_func(None)
        self.failIf(store.has_default_sort_func())

if __name__ == '__main__':
    unittest.main()