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