|
| 1 | +'''Test idlelib.help_about. |
| 2 | +
|
| 3 | +Coverage: |
| 4 | +''' |
| 5 | +from idlelib import aboutDialog as help_about |
| 6 | +from idlelib import textView as textview |
| 7 | +from idlelib.idle_test.mock_idle import Func |
| 8 | +from idlelib.idle_test.mock_tk import Mbox |
| 9 | +import unittest |
| 10 | + |
| 11 | +About = help_about.AboutDialog |
| 12 | +class 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 | + |
| 21 | +class DisplayFileTest(unittest.TestCase): |
| 22 | + "Test that .txt files are found and properly decoded." |
| 23 | + dialog = Dummy_about_dialog() |
| 24 | + |
| 25 | + @classmethod |
| 26 | + def setUpClass(cls): |
| 27 | + cls.orig_mbox = textview.tkMessageBox |
| 28 | + cls.orig_view = textview.view_text |
| 29 | + cls.mbox = Mbox() |
| 30 | + cls.view = Func() |
| 31 | + textview.tkMessageBox = cls.mbox |
| 32 | + textview.view_text = cls.view |
| 33 | + cls.About = Dummy_about_dialog() |
| 34 | + |
| 35 | + @classmethod |
| 36 | + def tearDownClass(cls): |
| 37 | + textview.tkMessageBox = cls.orig_mbox |
| 38 | + textview.view_text = cls.orig_view |
| 39 | + |
| 40 | + def test_file_isplay(self): |
| 41 | + for handler in (self.dialog.idle_credits, |
| 42 | + self.dialog.idle_readme, |
| 43 | + self.dialog.idle_news): |
| 44 | + self.mbox.showerror.message = '' |
| 45 | + self.view.called = False |
| 46 | + handler() |
| 47 | + self.assertEqual(self.mbox.showerror.message, '') |
| 48 | + self.assertEqual(self.view.called, True) |
| 49 | + |
| 50 | + |
| 51 | +if __name__ == '__main__': |
| 52 | + unittest.main(verbosity=2) |
0 commit comments