Issue #21477: Idle htest: merge and modify run and runall; add many tests.

Patch by Saimadhav Heblikar
This commit is contained in:
Terry Jan Reedy 2014-05-24 18:48:18 -04:00
parent 10cbb1e463
commit 1b392ffe67
18 changed files with 412 additions and 179 deletions

View file

@ -13,6 +13,7 @@ XXX TO DO:
import os
import sys
import pyclbr
import re
from idlelib import PyShell
from idlelib.WindowList import ListedToplevel
@ -21,11 +22,15 @@ from idlelib.configHandler import idleConf
class ClassBrowser:
def __init__(self, flist, name, path):
def __init__(self, flist, name, path, _htest=False):
# XXX This API should change, if the file doesn't end in ".py"
# XXX the code here is bogus!
"""
_htest - bool, change box when location running htest.
"""
self.name = name
self.file = os.path.join(path[0], self.name + ".py")
self._htest = _htest
self.init(flist)
def close(self, event=None):
@ -40,6 +45,9 @@ class ClassBrowser:
self.top = top = ListedToplevel(flist.root)
top.protocol("WM_DELETE_WINDOW", self.close)
top.bind("<Escape>", self.close)
if self._htest: # place dialog below parent if running htest
top.geometry("+%d+%d" %
(flist.root.winfo_rootx(), flist.root.winfo_rooty() + 200))
self.settitle()
top.focus_set()
# create scrolled canvas
@ -202,7 +210,7 @@ class MethodBrowserTreeItem(TreeItem):
edit = PyShell.flist.open(self.file)
edit.gotoline(self.cl.methods[self.name])
def main():
def _class_browser(parent): #Wrapper for htest
try:
file = __file__
except NameError:
@ -213,9 +221,9 @@ def main():
file = sys.argv[0]
dir, file = os.path.split(file)
name = os.path.splitext(file)[0]
ClassBrowser(PyShell.flist, name, [dir])
if sys.stdin is sys.__stdin__:
mainloop()
flist = PyShell.PyShellFileList(parent)
ClassBrowser(flist, name, [dir], _htest=True)
if __name__ == "__main__":
main()
from idlelib.idle_test.htest import run
run(_class_browser)