bpo-33855: Still more edits and minimal tests for IDLE (GH-7784)

Part 3 of 3, continuing PR #7689. This covers 14 idlelib modules and their tests,
rpc to zoomheight except for run (already done) and tooltip (being done separately).
This commit is contained in:
Terry Jan Reedy 2018-06-19 19:12:52 -04:00 committed by GitHub
parent 00f9edb98d
commit 4d92158f4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 358 additions and 97 deletions

View file

@ -5,20 +5,18 @@ This file could be expanded to include traceback overrides
Revise if output destination changes (http://bugs.python.org/issue18318).
Make sure warnings module is left unaltered (http://bugs.python.org/issue18081).
'''
from idlelib import run
from idlelib import pyshell as shell
import unittest
from test.support import captured_stderr
import warnings
# Try to capture default showwarning before Idle modules are imported.
showwarning = warnings.showwarning
# But if we run this file within idle, we are in the middle of the run.main loop
# and default showwarnings has already been replaced.
running_in_idle = 'idle' in showwarning.__name__
from idlelib import run
from idlelib import pyshell as shell
# The following was generated from pyshell.idle_formatwarning
# and checked as matching expectation.
idlemsg = '''
@ -29,6 +27,7 @@ UserWarning: Test
'''
shellmsg = idlemsg + ">>> "
class RunWarnTest(unittest.TestCase):
@unittest.skipIf(running_in_idle, "Does not work when run within Idle.")
@ -46,6 +45,7 @@ class RunWarnTest(unittest.TestCase):
# The following uses .splitlines to erase line-ending differences
self.assertEqual(idlemsg.splitlines(), f.getvalue().splitlines())
class ShellWarnTest(unittest.TestCase):
@unittest.skipIf(running_in_idle, "Does not work when run within Idle.")
@ -70,4 +70,4 @@ class ShellWarnTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main(verbosity=2, exit=False)
unittest.main(verbosity=2)