blob: 3f7ff65f2472dac75deb7d501f4ea672f1e77b26 [file] [log] [blame]
Guilherme Polocda93aa2009-01-28 13:09:03 +00001import os
Benjamin Petersonbf4464a2009-03-26 21:30:10 +00002import unittest
Guilherme Polocda93aa2009-01-28 13:09:03 +00003from test import test_support
4
Zachary Ware2460dc82014-05-02 10:33:49 -05005# Skip this test if _tkinter wasn't built or gui resource is not available.
R. David Murray597ebab2009-03-31 18:32:17 +00006test_support.import_module('_tkinter')
Zachary Ware2460dc82014-05-02 10:33:49 -05007test_support.requires('gui')
R. David Murray597ebab2009-03-31 18:32:17 +00008
Ned Deily46268c42011-07-03 21:52:35 -07009this_dir = os.path.dirname(os.path.abspath(__file__))
10lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,
11 'lib-tk', 'test'))
12
13with test_support.DirsOnSysPath(lib_tk_test):
14 import runtktests
15
Serhiy Storchakad3ea0652014-08-24 09:07:09 +030016import Tkinter as tkinter
R. David Murray597ebab2009-03-31 18:32:17 +000017import ttk
R. David Murray59beec32009-03-30 19:04:00 +000018from _tkinter import TclError
19
Serhiy Storchakad3ea0652014-08-24 09:07:09 +030020root = None
Guilherme Polo7a77ee82009-01-28 19:28:04 +000021try:
Serhiy Storchakad3ea0652014-08-24 09:07:09 +030022 root = tkinter.Tk()
23 button = ttk.Button(root)
24 button.destroy()
25 del button
26except TclError as msg:
Guilherme Polo7a77ee82009-01-28 19:28:04 +000027 # assuming ttk is not available
Benjamin Peterson888a39b2009-03-26 20:48:25 +000028 raise unittest.SkipTest("ttk not available: %s" % msg)
Serhiy Storchakad3ea0652014-08-24 09:07:09 +030029finally:
30 if root is not None:
31 root.destroy()
32 del root
Guilherme Polo7a77ee82009-01-28 19:28:04 +000033
Zachary Ware9ce635f2014-06-02 16:01:16 -050034def test_main():
Nick Coghlan7df72dc2009-10-17 14:40:54 +000035 with test_support.DirsOnSysPath(lib_tk_test):
Serhiy Storchakad3ea0652014-08-24 09:07:09 +030036 test_support.run_unittest(
37 *runtktests.get_tests(text=False, packages=['test_ttk']))
Guilherme Polocda93aa2009-01-28 13:09:03 +000038
39if __name__ == '__main__':
Zachary Ware9ce635f2014-06-02 16:01:16 -050040 test_main()