• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"Test debugobj, coverage 40%."
2
3from idlelib import debugobj
4import unittest
5
6
7class ObjectTreeItemTest(unittest.TestCase):
8
9    def test_init(self):
10        ti = debugobj.ObjectTreeItem('label', 22)
11        self.assertEqual(ti.labeltext, 'label')
12        self.assertEqual(ti.object, 22)
13        self.assertEqual(ti.setfunction, None)
14
15
16class ClassTreeItemTest(unittest.TestCase):
17
18    def test_isexpandable(self):
19        ti = debugobj.ClassTreeItem('label', 0)
20        self.assertTrue(ti.IsExpandable())
21
22
23class AtomicObjectTreeItemTest(unittest.TestCase):
24
25    def test_isexpandable(self):
26        ti = debugobj.AtomicObjectTreeItem('label', 0)
27        self.assertFalse(ti.IsExpandable())
28
29
30class SequenceTreeItemTest(unittest.TestCase):
31
32    def test_isexpandable(self):
33        ti = debugobj.SequenceTreeItem('label', ())
34        self.assertFalse(ti.IsExpandable())
35        ti = debugobj.SequenceTreeItem('label', (1,))
36        self.assertTrue(ti.IsExpandable())
37
38    def test_keys(self):
39        ti = debugobj.SequenceTreeItem('label', 'abc')
40        self.assertEqual(list(ti.keys()), [0, 1, 2])
41
42
43class DictTreeItemTest(unittest.TestCase):
44
45    def test_isexpandable(self):
46        ti = debugobj.DictTreeItem('label', {})
47        self.assertFalse(ti.IsExpandable())
48        ti = debugobj.DictTreeItem('label', {1:1})
49        self.assertTrue(ti.IsExpandable())
50
51    def test_keys(self):
52        ti = debugobj.DictTreeItem('label', {1:1, 0:0, 2:2})
53        self.assertEqual(ti.keys(), [0, 1, 2])
54
55
56if __name__ == '__main__':
57    unittest.main(verbosity=2)
58