blob: 49ca53fa62ff74213c6eec7be7bd3e8888f9c966 [file] [log] [blame]
Guilherme Polobbb7efd2009-02-09 19:21:21 +00001import os
Benjamin Peterson8e1a3382009-03-29 22:27:26 +00002import unittest
Guilherme Polobbb7efd2009-02-09 19:21:21 +00003from test import test_support
4
R. David Murray597ebab2009-03-31 18:32:17 +00005# Skip test if _tkinter wasn't built.
6test_support.import_module('_tkinter')
7
8import Tkinter
9
Guilherme Polo55bdb8e2009-02-09 19:57:04 +000010try:
11 Tkinter.Button()
12except Tkinter.TclError, msg:
13 # assuming tk is not available
Benjamin Peterson888a39b2009-03-26 20:48:25 +000014 raise unittest.SkipTest("tk not available: %s" % msg)
Guilherme Polo55bdb8e2009-02-09 19:57:04 +000015
Guilherme Polobbb7efd2009-02-09 19:21:21 +000016this_dir = os.path.dirname(os.path.abspath(__file__))
17lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,
18 'lib-tk', 'test'))
Guilherme Polobbb7efd2009-02-09 19:21:21 +000019
Nick Coghlan53a9dc92009-10-18 10:56:21 +000020with test_support.DirsOnSysPath(lib_tk_test):
21 import runtktests
Guilherme Polobbb7efd2009-02-09 19:21:21 +000022
23def test_main(enable_gui=False):
24 if enable_gui:
25 if test_support.use_resources is None:
26 test_support.use_resources = ['gui']
27 elif 'gui' not in test_support.use_resources:
28 test_support.use_resources.append('gui')
29
Nick Coghlan53a9dc92009-10-18 10:56:21 +000030 with test_support.DirsOnSysPath(lib_tk_test):
31 test_support.run_unittest(
Guilherme Polobbb7efd2009-02-09 19:21:21 +000032 *runtktests.get_tests(text=False, packages=['test_tkinter']))
33
34if __name__ == '__main__':
35 test_main(enable_gui=True)