source: python/trunk/Lib/test/test_ttk_guionly.py

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1import os
2import unittest
3from test import test_support
4
5# Skip this test if _tkinter wasn't built.
6test_support.import_module('_tkinter')
7
8this_dir = os.path.dirname(os.path.abspath(__file__))
9lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,
10 'lib-tk', 'test'))
11
12with test_support.DirsOnSysPath(lib_tk_test):
13 import runtktests
14
15# Skip test if tk cannot be initialized.
16runtktests.check_tk_availability()
17
18import ttk
19from _tkinter import TclError
20
21try:
22 ttk.Button()
23except TclError, msg:
24 # assuming ttk is not available
25 raise unittest.SkipTest("ttk not available: %s" % msg)
26
27def test_main(enable_gui=False):
28 if enable_gui:
29 if test_support.use_resources is None:
30 test_support.use_resources = ['gui']
31 elif 'gui' not in test_support.use_resources:
32 test_support.use_resources.append('gui')
33
34 with test_support.DirsOnSysPath(lib_tk_test):
35 from test_ttk.support import get_tk_root
36 try:
37 test_support.run_unittest(
38 *runtktests.get_tests(text=False, packages=['test_ttk']))
39 finally:
40 get_tk_root().destroy()
41
42if __name__ == '__main__':
43 test_main(enable_gui=True)
Note: See TracBrowser for help on using the repository browser.