summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ttk_guionly.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/Lib/test/test_ttk_guionly.py b/Lib/test/test_ttk_guionly.py
index e7a654f2e4..fcdedac34d 100644
--- a/Lib/test/test_ttk_guionly.py
+++ b/Lib/test/test_ttk_guionly.py
@@ -6,7 +6,7 @@ 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.
support.requires('gui')
@@ -14,20 +14,24 @@ 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():
- try:
- support.run_unittest(
- *runtktests.get_tests(text=False, packages=['test_ttk']))
- finally:
- get_tk_root().destroy()
+ support.run_unittest(
+ *runtktests.get_tests(text=False, packages=['test_ttk']))
if __name__ == '__main__':
test_main()