diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-07-15 03:07:21 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-07-15 03:07:21 (GMT) |
commit | af0dce939ce1e402cfd530d925e8f30a755a63ef (patch) | |
tree | d3d5fcea8cdf36e182a8916fa38233bee9f88c93 /Lib/idlelib | |
parent | 5d93f408d8ede65e3df7a35bcbf3cb2497d6ac5f (diff) | |
download | cpython-af0dce939ce1e402cfd530d925e8f30a755a63ef.zip cpython-af0dce939ce1e402cfd530d925e8f30a755a63ef.tar.gz cpython-af0dce939ce1e402cfd530d925e8f30a755a63ef.tar.bz2 |
Issue #21982: Add minimal unittest for configDialog with 46% coverage.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/configDialog.py | 12 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_configdialog.py | 32 |
2 files changed, 41 insertions, 3 deletions
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py index 56c1bb8..449ca0f 100644 --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configDialog.py @@ -23,9 +23,10 @@ from idlelib import macosxSupport class ConfigDialog(Toplevel): - def __init__(self,parent,title,_htest=False): + def __init__(self, parent, title, _htest=False, _utest=False): """ _htest - bool, change box location when running htest + _utest - bool, don't wait_window when running unittest """ Toplevel.__init__(self, parent) self.wm_withdraw() @@ -68,8 +69,9 @@ class ConfigDialog(Toplevel): self.LoadConfigs() self.AttachVarCallbacks() #avoid callbacks during LoadConfigs - self.wm_deiconify() - self.wait_window() + if not _utest: + self.wm_deiconify() + self.wait_window() def CreateWidgets(self): self.tabPages = TabbedPageSet(self, @@ -1156,5 +1158,9 @@ class ConfigDialog(Toplevel): pass if __name__ == '__main__': + import unittest + unittest.main('idlelib.idle_test.test_configdialog', + verbosity=2, exit=False) + from idlelib.idle_test.htest import run run(ConfigDialog) diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py new file mode 100644 index 0000000..3fbc822 --- /dev/null +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -0,0 +1,32 @@ +'''Unittests for idlelib/configHandler.py + +Coverage: 46% just by creating dialog. The other half is change code. + +''' +import unittest +from test.test_support import requires +from Tkinter import Tk +from idlelib.configDialog import ConfigDialog +from idlelib.macosxSupport import _initializeTkVariantTests + + +class ConfigDialogTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + requires('gui') + cls.root = Tk() + _initializeTkVariantTests(cls.root) + + @classmethod + def tearDownClass(cls): + cls.root.destroy() + del cls.root + + def test_dialog(self): + d=ConfigDialog(self.root, 'Test', _utest=True) + d.destroy() + + +if __name__ == '__main__': + unittest.main(verbosity=2) |