• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"Test statusbar, coverage 100%."
2
3from idlelib import statusbar
4import unittest
5from test.support import requires
6from tkinter import Tk
7
8
9class Test(unittest.TestCase):
10
11    @classmethod
12    def setUpClass(cls):
13        requires('gui')
14        cls.root = Tk()
15        cls.root.withdraw()
16
17    @classmethod
18    def tearDownClass(cls):
19        cls.root.update_idletasks()
20        cls.root.destroy()
21        del cls.root
22
23    def test_init(self):
24        bar = statusbar.MultiStatusBar(self.root)
25        self.assertEqual(bar.labels, {})
26
27    def test_set_label(self):
28        bar = statusbar.MultiStatusBar(self.root)
29        bar.set_label('left', text='sometext', width=10)
30        self.assertIn('left', bar.labels)
31        left = bar.labels['left']
32        self.assertEqual(left['text'], 'sometext')
33        self.assertEqual(left['width'], 10)
34        bar.set_label('left', text='revised text')
35        self.assertEqual(left['text'], 'revised text')
36        bar.set_label('right', text='correct text')
37        self.assertEqual(bar.labels['right']['text'], 'correct text')
38
39
40if __name__ == '__main__':
41    unittest.main(verbosity=2)
42