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