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