1 import os 2 from test import test_support 3 4 # Skip test if _tkinter wasn't built. 5 test_support.import_module('_tkinter') 6 7 this_dir = os.path.dirname(os.path.abspath(__file__)) 8 lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir, 9 'lib-tk', 'test')) 10 11 with test_support.DirsOnSysPath(lib_tk_test): 12 import runtktests 13 14 # Skip test if tk cannot be initialized. 15 runtktests.check_tk_availability() 16 17 def 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 28 if __name__ == '__main__': 29 test_main(enable_gui=True) 30