diff options
-rw-r--r-- | Lib/idlelib/aboutDialog.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_helpabout.py | 52 | ||||
-rw-r--r-- | Lib/idlelib/textView.py | 4 | ||||
-rw-r--r-- | Misc/NEWS | 5 |
4 files changed, 64 insertions, 1 deletions
diff --git a/Lib/idlelib/aboutDialog.py b/Lib/idlelib/aboutDialog.py index 40ea8ec..c9adc08 100644 --- a/Lib/idlelib/aboutDialog.py +++ b/Lib/idlelib/aboutDialog.py @@ -129,7 +129,7 @@ class AboutDialog(Toplevel): self.display_file_text('About - Readme', 'README.txt', 'ascii') def ShowIDLENEWS(self): - self.display_file_text('About - NEWS', 'NEWS.txt', 'ascii') + self.display_file_text('About - NEWS', 'NEWS.txt', 'utf-8') def display_printer_text(self, title, printer): printer._Printer__setup() @@ -144,5 +144,7 @@ class AboutDialog(Toplevel): self.destroy() if __name__ == '__main__': + import unittest + unittest.main('idlelib.idle_test.test_helpabout', verbosity=2, exit=False) from idlelib.idle_test.htest import run run(AboutDialog) diff --git a/Lib/idlelib/idle_test/test_helpabout.py b/Lib/idlelib/idle_test/test_helpabout.py new file mode 100644 index 0000000..0046f87 --- /dev/null +++ b/Lib/idlelib/idle_test/test_helpabout.py @@ -0,0 +1,52 @@ +'''Test idlelib.help_about. + +Coverage: +''' +from idlelib import aboutDialog as help_about +from idlelib import textView as textview +from idlelib.idle_test.mock_idle import Func +from idlelib.idle_test.mock_tk import Mbox +import unittest + +About = help_about.AboutDialog +class Dummy_about_dialog(): + # Dummy class for testing file display functions. + idle_credits = About.ShowIDLECredits.im_func + idle_readme = About.ShowIDLEAbout.im_func + idle_news = About.ShowIDLENEWS.im_func + # Called by the above + display_file_text = About.display_file_text.im_func + + +class DisplayFileTest(unittest.TestCase): + "Test that .txt files are found and properly decoded." + dialog = Dummy_about_dialog() + + @classmethod + def setUpClass(cls): + cls.orig_mbox = textview.tkMessageBox + cls.orig_view = textview.view_text + cls.mbox = Mbox() + cls.view = Func() + textview.tkMessageBox = cls.mbox + textview.view_text = cls.view + cls.About = Dummy_about_dialog() + + @classmethod + def tearDownClass(cls): + textview.tkMessageBox = cls.orig_mbox + textview.view_text = cls.orig_view.im_func + + def test_file_isplay(self): + for handler in (self.dialog.idle_credits, + self.dialog.idle_readme, + self.dialog.idle_news): + self.mbox.showerror.message = '' + self.view.called = False + handler() + self.assertEqual(self.mbox.showerror.message, '') + self.assertEqual(self.view.called, True) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py index 8687d40..b8c4ac1 100644 --- a/Lib/idlelib/textView.py +++ b/Lib/idlelib/textView.py @@ -79,6 +79,10 @@ def view_file(parent, title, filename, encoding=None, modal=True): tkMessageBox.showerror(title='File Load Error', message='Unable to load file %r .' % filename, parent=parent) + except UnicodeDecodeError as err: + showerror(title='Unicode Decode Error', + message=str(err), + parent=parent) else: return view_text(parent, title, textFile.read(), modal) @@ -10,6 +10,11 @@ Build - Issue #26930: Update Windows builds to use OpenSSL 1.0.2h. +IDLE +---- + +- Issue #27365: Fix about dialog. + What's New in Python 2.7.12 release candidate 1? ================================================ |