1import os 2from test import test_support 3 4# Skip test if _tkinter wasn't built. 5test_support.import_module('_tkinter') 6 7this_dir = os.path.dirname(os.path.abspath(__file__)) 8lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir, 9 'lib-tk', 'test')) 10 11with test_support.DirsOnSysPath(lib_tk_test): 12 import runtktests 13 14# Skip test if tk cannot be initialized. 15runtktests.check_tk_availability() 16 17def test_main(enable_gui=False): 18 if enable_gui: 19 if test_support.use_resources is None: 20 test_support.use_resources = ['gui'] 21 elif 'gui' not in test_support.use_resources: 22 test_support.use_resources.append('gui') 23 24 with test_support.DirsOnSysPath(lib_tk_test): 25 test_support.run_unittest( 26 *runtktests.get_tests(text=False, packages=['test_tkinter'])) 27 28if __name__ == '__main__': 29 test_main(enable_gui=True) 30