Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-33855: Minimally test all IDLE modules. #7689

Merged
merged 30 commits into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0d3dcc1
Edit test_autocomplete.
terryjreedy Jun 14, 2018
f819957
Edit test_autocomplete.
terryjreedy Jun 14, 2018
a661e32
Add test_autocomplete_w.
terryjreedy Jun 14, 2018
858d9d4
Edit autocomplete_w.py.
terryjreedy Jun 14, 2018
b011fd3
Edit test_calltips.
terryjreedy Jun 14, 2018
3f4e9cf
Add idle_test/template.py.
terryjreedy Jun 14, 2018
4572cde
Edit test_autoexpand.
terryjreedy Jun 14, 2018
c19d810
Add blurb.
terryjreedy Jun 14, 2018
dedc726
Edit test_browser.
terryjreedy Jun 14, 2018
8658eab
Edit template.
terryjreedy Jun 14, 2018
59b504b
Edit template.
terryjreedy Jun 14, 2018
23375c7
Edit template.
terryjreedy Jun 14, 2018
3d23f61
Add test_calltip_w.py.
terryjreedy Jun 14, 2018
c0328ce
Edit tests for codecontext, colorizer, config, and config_key.
terryjreedy Jun 14, 2018
d764c73
Edit test_calltips.
terryjreedy Jun 14, 2018
9248976
Move tested module import first.
terryjreedy Jun 14, 2018
ce7c113
Edit template and test_autocomple_w.
terryjreedy Jun 14, 2018
bc81598
templage whitespace
terryjreedy Jun 14, 2018
ad6232f
Edit test_configdialog and test_debugger.
terryjreedy Jun 15, 2018
e3b77a1
Edit autocomplete, autocomplete_w, calltip_w, colorizer.
terryjreedy Jun 15, 2018
126d2d0
Add test_debugger_r, edit test_debugger, debugger, debugger_r.
terryjreedy Jun 15, 2018
5a81d36
Edit debugobj, debugobj_r, add test_debugobj, test_debugobj_r.
terryjreedy Jun 15, 2018
7828bfc
Augment template.py.
terryjreedy Jun 15, 2018
41b4d43
Edit test_delegator.
terryjreedy Jun 15, 2018
7256456
Edit editor and test_editor.
terryjreedy Jun 15, 2018
2eabc75
To template, add cleanup needed for EditorWindow.
terryjreedy Jun 15, 2018
2cebaa1
Edit filelist and add test_filelist.
terryjreedy Jun 15, 2018
2a86ca0
Edit grep and test_grep.
terryjreedy Jun 15, 2018
7d26bf7
Edit help and test_help.
terryjreedy Jun 15, 2018
cce485c
whitespace
terryjreedy Jun 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Lib/idlelib/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def get_entity(self, name):

AutoComplete.reload()


if __name__ == '__main__':
from unittest import main
main('idlelib.idle_test.test_autocomplete', verbosity=2)
7 changes: 7 additions & 0 deletions Lib/idlelib/autocomplete_w.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,10 @@ def hide_window(self):
self.listbox = None
self.autocompletewindow.destroy()
self.autocompletewindow = None


if __name__ == '__main__':
from unittest import main
main('idlelib.idle_test.test_autocomplete_w', verbosity=2, exit=False)

# TODO: autocomplete/w htest here
5 changes: 4 additions & 1 deletion Lib/idlelib/calltip_w.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def calltip_hide(event):
text.bind("<<calltip-hide>>", calltip_hide)
text.focus_set()

if __name__=='__main__':
if __name__ == '__main__':
from unittest import main
main('idlelib.idle_test.test_calltips', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(_calltip_window)
5 changes: 2 additions & 3 deletions Lib/idlelib/colorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,8 @@ def _color_delegator(parent): # htest #
p.insertfilter(d)

if __name__ == "__main__":
import unittest
unittest.main('idlelib.idle_test.test_colorizer',
verbosity=2, exit=False)
from unittest import main
main('idlelib.idle_test.test_colorizer', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(_color_delegator)
10 changes: 8 additions & 2 deletions Lib/idlelib/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Idb(bdb.Bdb):

def __init__(self, gui):
self.gui = gui
self.gui = gui # An instance of Debugger or proxy of remote.
bdb.Bdb.__init__(self)

def user_line(self, frame):
Expand Down Expand Up @@ -63,7 +63,7 @@ def __init__(self, pyshell, idb=None):
if idb is None:
idb = Idb(self)
self.pyshell = pyshell
self.idb = idb
self.idb = idb # If passed, a proxy of remote instance.
self.frame = None
self.make_gui()
self.interacting = 0
Expand Down Expand Up @@ -542,3 +542,9 @@ def load_dict(self, dict, force=0, rpc_client=None):

def close(self):
self.frame.destroy()

if __name__ == "__main__":
from unittest import main
main('idlelib.idle_test.test_debugger', verbosity=2, exit=False)

# TODO: htest?
5 changes: 5 additions & 0 deletions Lib/idlelib/debugger_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,8 @@ def restart_subprocess_debugger(rpcclt):
idb_adap_oid_ret = rpcclt.remotecall("exec", "start_the_debugger",\
(gui_adap_oid,), {})
assert idb_adap_oid_ret == idb_adap_oid, 'Idb restarted with different oid'


if __name__ == "__main__":
from unittest import main
main('idlelib.idle_test.test_debugger', verbosity=2, exit=False)
5 changes: 4 additions & 1 deletion Lib/idlelib/debugobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def GetSubList(self):

class AtomicObjectTreeItem(ObjectTreeItem):
def IsExpandable(self):
return 0
return False

class SequenceTreeItem(ObjectTreeItem):
def IsExpandable(self):
Expand Down Expand Up @@ -135,5 +135,8 @@ def _object_browser(parent): # htest #
node.update()

if __name__ == '__main__':
from unittest import main
main('idlelib.idle_test.test_debugobj', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(_object_browser)
5 changes: 5 additions & 0 deletions Lib/idlelib/debugobj_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ def __getattr__(self, name):
def _GetSubList(self):
sub_list = self.sockio.remotecall(self.oid, "_GetSubList", (), {})
return [StubObjectTreeItem(self.sockio, oid) for oid in sub_list]


if __name__ == '__main__':
from unittest import main
main('idlelib.idle_test.test_debugobj_r', verbosity=2)
4 changes: 2 additions & 2 deletions Lib/idlelib/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,8 +1706,8 @@ def _editor_window(parent): # htest #
# edit.text.bind("<<close-window>>", edit.close_event)

if __name__ == '__main__':
import unittest
unittest.main('idlelib.idle_test.test_editor', verbosity=2, exit=False)
from unittest import main
main('idlelib.idle_test.test_editor', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(_editor_window)
20 changes: 10 additions & 10 deletions Lib/idlelib/filelist.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
"idlelib.filelist"

from tkinter import *
import tkinter.messagebox as tkMessageBox
import os
from tkinter import messagebox as tkMessageBox


class FileList:
Expand Down Expand Up @@ -111,7 +111,8 @@ def canonize(self, filename):
return os.path.normpath(filename)


def _test():
def _test(): # TODO check and convert to htest
from tkinter import Tk
from idlelib.editor import fixwordbreaks
from idlelib.run import fix_scaling
import sys
Expand All @@ -120,13 +121,12 @@ def _test():
fixwordbreaks(root)
root.withdraw()
flist = FileList(root)
if sys.argv[1:]:
for filename in sys.argv[1:]:
flist.open(filename)
else:
flist.new()
flist.new()
if flist.inversedict:
root.mainloop()

if __name__ == '__main__':
_test()
from unittest import main
main('idlelib.idle_test.test_filelist', verbosity=2)

# _test()
4 changes: 2 additions & 2 deletions Lib/idlelib/grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ def show_grep_dialog():
button.pack()

if __name__ == "__main__":
import unittest
unittest.main('idlelib.idle_test.test_grep', verbosity=2, exit=False)
from unittest import main
main('idlelib.idle_test.test_grep', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(_grep_dialog)
3 changes: 3 additions & 0 deletions Lib/idlelib/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,5 +271,8 @@ def show_idlehelp(parent):
HelpWindow(parent, filename, 'IDLE Help (%s)' % python_version())

if __name__ == '__main__':
from unittest import main
main('idlelib.idle_test.test_help', verbosity=2, exit=False)

from idlelib.idle_test.htest import run
run(show_idlehelp)
30 changes: 30 additions & 0 deletions Lib/idlelib/idle_test/template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"Test , coverage %."

from idlelib import
import unittest
from test.support import requires
from tkinter import Tk


class Test(unittest.TestCase):

@classmethod
def setUpClass(cls):
requires('gui')
cls.root = Tk()
cls.root.withdraw()

@classmethod
def tearDownClass(cls):
cls.root.update_idletasks()
## for id in cls.root.tk.call('after', 'info'):
## cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root

def test_init(self):
self.assert


if __name__ == '__main__':
unittest.main(verbosity=2)
7 changes: 1 addition & 6 deletions Lib/idlelib/idle_test/test_autocomplete.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
''' Test autocomplete and autocomple_w
"Test autocomplete, coverage 57%."

Coverage of autocomple: 56%
'''
import unittest
from test.support import requires
from tkinter import Tk, Text
Expand All @@ -11,9 +9,6 @@
from idlelib.idle_test.mock_idle import Func
from idlelib.idle_test.mock_tk import Event

class AutoCompleteWindow:
def complete():
return

class DummyEditwin:
def __init__(self, root, text):
Expand Down
32 changes: 32 additions & 0 deletions Lib/idlelib/idle_test/test_autocomplete_w.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"Test autocomplete_w, coverage 11%."

import unittest
from test.support import requires
from tkinter import Tk, Text

import idlelib.autocomplete_w as acw


class AutoCompleteWindowTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
requires('gui')
cls.root = Tk()
cls.root.withdraw()
cls.text = Text(cls.root)
cls.acw = acw.AutoCompleteWindow(cls.text)

@classmethod
def tearDownClass(cls):
del cls.text, cls.acw
cls.root.update_idletasks()
cls.root.destroy()
del cls.root

def test_init(self):
self.assertEqual(self.acw.widget, self.text)


if __name__ == '__main__':
unittest.main(verbosity=2)
30 changes: 21 additions & 9 deletions Lib/idlelib/idle_test/test_autoexpand.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Unit tests for idlelib.autoexpand"""
"Test autoexpand, coverage 100%."

from idlelib.autoexpand import AutoExpand
import unittest
from test.support import requires
from tkinter import Text, Tk
#from idlelib.idle_test.mock_tk import Text
from idlelib.autoexpand import AutoExpand


class Dummy_Editwin:
Expand All @@ -15,15 +15,27 @@ class AutoExpandTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
if 'tkinter' in str(Text):
requires('gui')
cls.tk = Tk()
cls.text = Text(cls.tk)
else:
cls.text = Text()
requires('gui')
cls.tk = Tk()
cls.text = Text(cls.tk)
cls.auto_expand = AutoExpand(Dummy_Editwin(cls.text))
cls.auto_expand.bell = lambda: None

# If mock_tk.Text._decode understood indexes 'insert' with suffixed 'linestart',
# 'wordstart', and 'lineend', used by autoexpand, we could use the following
# to run these test on non-gui machines (but check bell).
## try:
## requires('gui')
## #raise ResourceDenied() # Uncomment to test mock.
## except ResourceDenied:
## from idlelib.idle_test.mock_tk import Text
## cls.text = Text()
## cls.text.bell = lambda: None
## else:
## from tkinter import Tk, Text
## cls.tk = Tk()
## cls.text = Text(cls.tk)

@classmethod
def tearDownClass(cls):
del cls.text, cls.auto_expand
Expand Down
16 changes: 6 additions & 10 deletions Lib/idlelib/idle_test/test_browser.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
""" Test idlelib.browser.
"Test browser, coverage 90%."

Coverage: 88%
(Higher, because should exclude 3 lines that .coveragerc won't exclude.)
"""
from idlelib import browser
from test.support import requires
import unittest
from unittest import mock
from idlelib.idle_test.mock_idle import Func

from collections import deque
import os.path
import pyclbr
from tkinter import Tk

from test.support import requires
import unittest
from unittest import mock
from idlelib.idle_test.mock_idle import Func

from idlelib import browser
from idlelib import filelist
from idlelib.tree import TreeNode

Expand Down
29 changes: 29 additions & 0 deletions Lib/idlelib/idle_test/test_calltip_w.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"Test calltip_w, coverage 18%."

from idlelib import calltip_w
import unittest
from test.support import requires
from tkinter import Tk, Text


class CallTipTest(unittest.TestCase):

@classmethod
def setUpClass(cls):
requires('gui')
cls.root = Tk()
cls.root.withdraw()
cls.text = Text(cls.root)
cls.calltip = calltip_w.CallTip(cls.text)

@classmethod
def tearDownClass(cls):
cls.root.update_idletasks()
cls.root.destroy()
del cls.text, cls.root

def test_init(self):
self.assertEqual(self.calltip.widget, self.text)

if __name__ == '__main__':
unittest.main(verbosity=2)
Loading