diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-08-09 20:26:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-09 20:26:37 (GMT) |
commit | 61f23cb62d6bdd72b61fc36abf4c1492493d71af (patch) | |
tree | 23bb3bf804def74a805dacd4aed1218b3af6d8c0 /Lib/idlelib/idle_test | |
parent | f421865c76a34a80c57350bcfbde664f4e80313d (diff) | |
download | cpython-61f23cb62d6bdd72b61fc36abf4c1492493d71af.zip cpython-61f23cb62d6bdd72b61fc36abf4c1492493d71af.tar.gz cpython-61f23cb62d6bdd72b61fc36abf4c1492493d71af.tar.bz2 |
bpo-41468: Improve and test IDLE run error exit (GH-21798)
A message box pops up when an unexpected error stops the run process. Tell users it is likely a random glitch, but report it if not.
(cherry picked from commit f2e161c27964a59bc5ab20d96f87ba5862c6222d)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r-- | Lib/idlelib/idle_test/test_run.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/Lib/idlelib/idle_test/test_run.py b/Lib/idlelib/idle_test/test_run.py index e2bdf1c..469c13d 100644 --- a/Lib/idlelib/idle_test/test_run.py +++ b/Lib/idlelib/idle_test/test_run.py @@ -1,9 +1,10 @@ -"Test run, coverage 42%." +"Test run, coverage 49%." from idlelib import run import unittest from unittest import mock -from test.support import captured_stderr +from idlelib.idle_test.mock_idle import Func +from test.support import captured_output, captured_stderr import io import sys @@ -323,5 +324,32 @@ class RecursionLimitTest(unittest.TestCase): self.assertEqual(func.__doc__, "more") +class HandleErrorTest(unittest.TestCase): + # Method of MyRPCServer + func = Func() + @mock.patch('idlelib.run.thread.interrupt_main', new=func) + def test_error(self): + eq = self.assertEqual + with captured_output('__stderr__') as err: + try: + raise EOFError + except EOFError: + run.MyRPCServer.handle_error(None, 'abc', '123') + eq(run.exit_now, True) + run.exit_now = False + eq(err.getvalue(), '') + + try: + raise IndexError + except IndexError: + run.MyRPCServer.handle_error(None, 'abc', '123') + eq(run.quitting, True) + run.quitting = False + msg = err.getvalue() + self.assertIn('abc', msg) + self.assertIn('123', msg) + self.assertIn('IndexError', msg) + eq(self.func.called, 2) + if __name__ == '__main__': unittest.main(verbosity=2) |