Guilherme Polo | bbb7efd | 2009-02-09 19:21:21 +0000 | [diff] [blame] | 1 | import os |
Benjamin Peterson | 8e1a338 | 2009-03-29 22:27:26 +0000 | [diff] [blame] | 2 | import unittest |
Guilherme Polo | bbb7efd | 2009-02-09 19:21:21 +0000 | [diff] [blame] | 3 | from test import test_support |
| 4 | |
R. David Murray | 597ebab | 2009-03-31 18:32:17 +0000 | [diff] [blame] | 5 | # Skip test if _tkinter wasn't built. |
| 6 | test_support.import_module('_tkinter') |
| 7 | |
| 8 | import Tkinter |
| 9 | |
Guilherme Polo | 55bdb8e | 2009-02-09 19:57:04 +0000 | [diff] [blame] | 10 | try: |
| 11 | Tkinter.Button() |
| 12 | except Tkinter.TclError, msg: |
| 13 | # assuming tk is not available |
Benjamin Peterson | 888a39b | 2009-03-26 20:48:25 +0000 | [diff] [blame] | 14 | raise unittest.SkipTest("tk not available: %s" % msg) |
Guilherme Polo | 55bdb8e | 2009-02-09 19:57:04 +0000 | [diff] [blame] | 15 | |
Guilherme Polo | bbb7efd | 2009-02-09 19:21:21 +0000 | [diff] [blame] | 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')) |
Guilherme Polo | bbb7efd | 2009-02-09 19:21:21 +0000 | [diff] [blame] | 19 | |
Nick Coghlan | 53a9dc9 | 2009-10-18 10:56:21 +0000 | [diff] [blame] | 20 | with test_support.DirsOnSysPath(lib_tk_test): |
| 21 | import runtktests |
Guilherme Polo | bbb7efd | 2009-02-09 19:21:21 +0000 | [diff] [blame] | 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 | |
Nick Coghlan | 53a9dc9 | 2009-10-18 10:56:21 +0000 | [diff] [blame] | 30 | with test_support.DirsOnSysPath(lib_tk_test): |
| 31 | test_support.run_unittest( |
Guilherme Polo | bbb7efd | 2009-02-09 19:21:21 +0000 | [diff] [blame] | 32 | *runtktests.get_tests(text=False, packages=['test_tkinter'])) |
| 33 | |
| 34 | if __name__ == '__main__': |
| 35 | test_main(enable_gui=True) |