blob: b8c1a4ca10077fa58e1a80bd09b42a5a7a40ef96 [file] [log] [blame]
Guilherme Polo9de29af2009-01-28 20:40:48 +00001import os
R. David Murraya21e4ca2009-03-31 23:16:50 +00002import unittest
3from test import support
4
5# Skip this test if _tkinter wasn't built.
6support.import_module('_tkinter')
7
Ned Deily41435352011-07-03 21:56:48 -07008# Skip test if tk cannot be initialized.
9from tkinter.test.support import check_tk_availability
10check_tk_availability()
11
R. David Murraya21e4ca2009-03-31 23:16:50 +000012from _tkinter import TclError
Guilherme Polo9de29af2009-01-28 20:40:48 +000013from tkinter import ttk
14from tkinter.test import runtktests
Antoine Pitrou560f9da2011-01-04 00:24:03 +000015from tkinter.test.support import get_tk_root
Guilherme Polo9de29af2009-01-28 20:40:48 +000016
17try:
18 ttk.Button()
19except TclError as msg:
20 # assuming ttk is not available
Benjamin Petersone549ead2009-03-28 21:42:05 +000021 raise unittest.SkipTest("ttk not available: %s" % msg)
Guilherme Polo9de29af2009-01-28 20:40:48 +000022
23def test_main(enable_gui=False):
24 if enable_gui:
25 if support.use_resources is None:
26 support.use_resources = ['gui']
27 elif 'gui' not in support.use_resources:
28 support.use_resources.append('gui')
29
Antoine Pitrou560f9da2011-01-04 00:24:03 +000030 try:
31 support.run_unittest(
32 *runtktests.get_tests(text=False, packages=['test_ttk']))
33 finally:
34 get_tk_root().destroy()
Guilherme Polo9de29af2009-01-28 20:40:48 +000035
36if __name__ == '__main__':
37 test_main(enable_gui=True)