1 | n/a | '''Test idlelib.help_about. |
---|
2 | n/a | |
---|
3 | n/a | Coverage: |
---|
4 | n/a | ''' |
---|
5 | n/a | from idlelib import help_about |
---|
6 | n/a | from idlelib import textview |
---|
7 | n/a | from idlelib.idle_test.mock_idle import Func |
---|
8 | n/a | from idlelib.idle_test.mock_tk import Mbox_func |
---|
9 | n/a | import unittest |
---|
10 | n/a | |
---|
11 | n/a | About = help_about.AboutDialog |
---|
12 | n/a | class Dummy_about_dialog(): |
---|
13 | n/a | # Dummy class for testing file display functions. |
---|
14 | n/a | idle_credits = About.ShowIDLECredits |
---|
15 | n/a | idle_readme = About.ShowIDLEAbout |
---|
16 | n/a | idle_news = About.ShowIDLENEWS |
---|
17 | n/a | # Called by the above |
---|
18 | n/a | display_file_text = About.display_file_text |
---|
19 | n/a | |
---|
20 | n/a | |
---|
21 | n/a | class DisplayFileTest(unittest.TestCase): |
---|
22 | n/a | dialog = Dummy_about_dialog() |
---|
23 | n/a | |
---|
24 | n/a | @classmethod |
---|
25 | n/a | def setUpClass(cls): |
---|
26 | n/a | cls.orig_error = textview.showerror |
---|
27 | n/a | cls.orig_view = textview.view_text |
---|
28 | n/a | cls.error = Mbox_func() |
---|
29 | n/a | cls.view = Func() |
---|
30 | n/a | textview.showerror = cls.error |
---|
31 | n/a | textview.view_text = cls.view |
---|
32 | n/a | cls.About = Dummy_about_dialog() |
---|
33 | n/a | |
---|
34 | n/a | @classmethod |
---|
35 | n/a | def tearDownClass(cls): |
---|
36 | n/a | textview.showerror = cls.orig_error |
---|
37 | n/a | textview.view_text = cls.orig_view |
---|
38 | n/a | |
---|
39 | n/a | def test_file_isplay(self): |
---|
40 | n/a | for handler in (self.dialog.idle_credits, |
---|
41 | n/a | self.dialog.idle_readme, |
---|
42 | n/a | self.dialog.idle_news): |
---|
43 | n/a | self.error.message = '' |
---|
44 | n/a | self.view.called = False |
---|
45 | n/a | with self.subTest(handler=handler): |
---|
46 | n/a | handler() |
---|
47 | n/a | self.assertEqual(self.error.message, '') |
---|
48 | n/a | self.assertEqual(self.view.called, True) |
---|
49 | n/a | |
---|
50 | n/a | |
---|
51 | n/a | if __name__ == '__main__': |
---|
52 | n/a | unittest.main(verbosity=2) |
---|