1import unittest 2from test import support 3from test.support import import_helper 4 5# Skip this test if _tkinter wasn't built. 6import_helper.import_module('_tkinter') 7 8# Skip test if tk cannot be initialized. 9support.requires('gui') 10 11import tkinter 12from _tkinter import TclError 13from tkinter import ttk 14 15 16def setUpModule(): 17 root = None 18 try: 19 root = tkinter.Tk() 20 button = ttk.Button(root) 21 button.destroy() 22 del button 23 except TclError as msg: 24 # assuming ttk is not available 25 raise unittest.SkipTest("ttk not available: %s" % msg) 26 finally: 27 if root is not None: 28 root.destroy() 29 del root 30 31def load_tests(loader, tests, pattern): 32 return loader.discover('tkinter.test.test_ttk') 33 34 35if __name__ == '__main__': 36 unittest.main() 37