cpython: a0e8f2d882a3 (original) (raw)

Mercurial > cpython

changeset 91491:a0e8f2d882a3 3.4

Issue #18592: Add unittests for SearchDialogBase. Patch by Phil Webster. [#18592]

Terry Jan Reedy tjreedy@udel.edu
date Mon, 30 Jun 2014 20:00:03 -0400
parents fcfa9c5a00fd
children b3f4616b9a94 e0561df131aa
files Lib/idlelib/SearchDialogBase.py Lib/idlelib/idle_test/test_searchdialogbase.py
diffstat 2 files changed, 213 insertions(+), 10 deletions(-)[+] [-] Lib/idlelib/SearchDialogBase.py 25 Lib/idlelib/idle_test/test_searchdialogbase.py 198

line wrap: on

line diff

--- a/Lib/idlelib/SearchDialogBase.py +++ b/Lib/idlelib/SearchDialogBase.py @@ -16,10 +16,12 @@ class SearchDialogBase: (make_button, create_command_buttons). These are bound to functions that execute the command.

top (level widget): set in create_widgets() called from open().

title (of dialog): class attribute, override in subclasses. icon (of dialog): ditto, use unclear if cannot minimize dialog. @@ -93,25 +96,27 @@ class SearchDialogBase: e = Entry(self.top, textvariable=var, exportselection=0) e.grid(row=self.row, column=1, sticky="nwe") self.row = self.row + 1

def create_entries(self): "Create one or more entry lines with make_entry."

def make_frame(self,labeltext=None): "Return gridded labeled Frame for option or other buttons." if labeltext: l = Label(self.top, text=labeltext) l.grid(row=self.row, column=0, sticky="nw")

def create_option_buttons(self): "Fill frame with Checkbuttons bound to SearchEngine booleanvars."

btn = Checkbutton(f, anchor="w", variable=self.engine.revar, @@ -144,7 +149,7 @@ class SearchDialogBase: def create_other_buttons(self): "Fill frame with buttons tied to other options."

btn = Radiobutton(f, anchor="w", variable=self.engine.backvar, value=1,

new file mode 100644 --- /dev/null +++ b/Lib/idlelib/idle_test/test_searchdialogbase.py @@ -0,0 +1,198 @@ +'''Unittests for idlelib/SearchDialogBase.py + +Coverage: 99%. The only thing not covered is inconsequential -- +testing skipping of suite when self.needwrapbutton is false. + +''' +import unittest +from test.support import requires +from tkinter import Tk, Toplevel, Frame, Label, BooleanVar, StringVar +from idlelib import SearchEngine as se +from idlelib import SearchDialogBase as sdb +from idlelib.idle_test.mock_idle import Func +from idlelib.idle_test.mock_tk import Var, Mbox + +# The following could help make some tests gui-free. +# However, they currently make radiobutton tests fail. +##def setUpModule(): +## # Replace tk objects used to initialize se.SearchEngine. +## se.BooleanVar = Var +## se.StringVar = Var +## +##def tearDownModule(): +## se.BooleanVar = BooleanVar +## se.StringVar = StringVar + +class SearchDialogBaseTest(unittest.TestCase): +

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ + + +if name == 'main':