Toplevel.__init__(self, parent)
self.wm_title(title)
self.protocol("WM_DELETE_WINDOW", self.destroy)
- HelpFrame(self, filename).grid(column=0, row=0, sticky='nsew')
+ self.frame = HelpFrame(self, filename)
+ self.frame.grid(column=0, row=0, sticky='nsew')
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
-def copy_strip():
+def copy_strip(): # pragma: no cover
"""Copy idle.html to idlelib/help.html, stripping trailing whitespace.
Files with trailing whitespace cannot be pushed to the git cpython
print(f'{src} copied to {dst}')
-def _helpwindow(parent):
+def show_idlehelp(parent):
"Create HelpWindow; called from Idle Help event handler."
filename = join(abspath(dirname(__file__)), 'help.html')
- if not isfile(filename):
+ if not isfile(filename): # pragma: no cover
# Try copy_strip, present message.
return
- HelpWindow(parent, filename, 'IDLE Help (%s)' % python_version())
+ return HelpWindow(parent, filename, 'IDLE Doc (%s)' % python_version())
if __name__ == '__main__':
main('idlelib.idle_test.test_help', verbosity=2, exit=False)
from idlelib.idle_test.htest import run
- run(_helpwindow)
+ run(show_idlehelp)
"<Escape>, [Cancel], or [X] prints None to shell"
}
-_helpwindow_spec = {
- 'file': 'help',
- 'kwds': {},
- 'msg': "If the help text displays, this works.\n"
- "Text is selectable. Window is scrollable."
- }
-
_io_binding_spec = {
'file': 'iomenu',
'kwds': {},
"Its only action is to close."
}
+show_idlehelp_spec = {
+ 'file': 'help',
+ 'kwds': {},
+ 'msg': "If the help text displays, this works.\n"
+ "Text is selectable. Window is scrollable."
+ }
+
_sidebar_number_scrolling_spec = {
'file': 'sidebar',
'kwds': {},
-"Test help, coverage 87%."
+"Test help, coverage 94%."
from idlelib import help
import unittest
from tkinter import Tk
-class HelpFrameTest(unittest.TestCase):
+class IdleDocTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
"By itself, this tests that file parsed without exception."
cls.root = root = Tk()
root.withdraw()
- helpfile = join(dirname(dirname(abspath(__file__))), 'help.html')
- cls.frame = help.HelpFrame(root, helpfile)
+ cls.window = help.show_idlehelp(root)
@classmethod
def tearDownClass(cls):
- del cls.frame
+ del cls.window
cls.root.update_idletasks()
cls.root.destroy()
del cls.root
- def test_line1(self):
- text = self.frame.text
+ def test_1window(self):
+ self.assertIn('IDLE Doc', self.window.wm_title())
+
+ def test_4text(self):
+ text = self.window.frame.text
self.assertEqual(text.get('1.0', '1.end'), ' IDLE ')