diff options
Diffstat (limited to 'Lib/test/test_ttk_guionly.py')
| -rw-r--r-- | Lib/test/test_ttk_guionly.py | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/Lib/test/test_ttk_guionly.py b/Lib/test/test_ttk_guionly.py index 3a3459b..fcdedac 100644 --- a/Lib/test/test_ttk_guionly.py +++ b/Lib/test/test_ttk_guionly.py @@ -6,35 +6,32 @@ from test import support support.import_module('_tkinter') # Make sure tkinter._fix runs to set up the environment -support.import_fresh_module('tkinter') +tkinter = support.import_fresh_module('tkinter') # Skip test if tk cannot be initialized. -from tkinter.test.support import check_tk_availability -check_tk_availability() +support.requires('gui') from _tkinter import TclError from tkinter import ttk from tkinter.test import runtktests -from tkinter.test.support import get_tk_root +root = None try: - ttk.Button() + root = tkinter.Tk() + button = ttk.Button(root) + button.destroy() + del button except TclError as msg: # assuming ttk is not available raise unittest.SkipTest("ttk not available: %s" % msg) +finally: + if root is not None: + root.destroy() + del root -def test_main(enable_gui=False): - if enable_gui: - if support.use_resources is None: - support.use_resources = ['gui'] - elif 'gui' not in support.use_resources: - support.use_resources.append('gui') - - try: - support.run_unittest( - *runtktests.get_tests(text=False, packages=['test_ttk'])) - finally: - get_tk_root().destroy() +def test_main(): + support.run_unittest( + *runtktests.get_tests(text=False, packages=['test_ttk'])) if __name__ == '__main__': - test_main(enable_gui=True) + test_main() |
