Home | History | Annotate | Download | only in test
      1 import os
      2 import unittest
      3 from test import test_support
      4 
      5 # Skip test if _tkinter wasn't built.

      6 test_support.import_module('_tkinter')
      7 
      8 import Tkinter
      9 
     10 try:
     11     Tkinter.Button()
     12 except Tkinter.TclError, msg:
     13     # assuming tk is not available

     14     raise unittest.SkipTest("tk not available: %s" % msg)
     15 
     16 this_dir = os.path.dirname(os.path.abspath(__file__))
     17 lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,
     18     'lib-tk', 'test'))
     19 
     20 with test_support.DirsOnSysPath(lib_tk_test):
     21     import runtktests
     22 
     23 def 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 
     30     with test_support.DirsOnSysPath(lib_tk_test):
     31         test_support.run_unittest(
     32             *runtktests.get_tests(text=False, packages=['test_tkinter']))
     33 
     34 if __name__ == '__main__':
     35     test_main(enable_gui=True)
     36