Guilherme Polo | bbb7efd | 2009-02-09 19:21:21 +0000 | [diff] [blame] | 1 | import os |
| 2 | import sys |
Benjamin Peterson | 8e1a338 | 2009-03-29 22:27:26 +0000 | [diff] [blame^] | 3 | import unittest |
Guilherme Polo | 55bdb8e | 2009-02-09 19:57:04 +0000 | [diff] [blame] | 4 | import Tkinter |
Guilherme Polo | bbb7efd | 2009-02-09 19:21:21 +0000 | [diff] [blame] | 5 | from test import test_support |
| 6 | |
Guilherme Polo | 55bdb8e | 2009-02-09 19:57:04 +0000 | [diff] [blame] | 7 | try: |
| 8 | Tkinter.Button() |
| 9 | except Tkinter.TclError, msg: |
| 10 | # assuming tk is not available |
Benjamin Peterson | 888a39b | 2009-03-26 20:48:25 +0000 | [diff] [blame] | 11 | raise unittest.SkipTest("tk not available: %s" % msg) |
Guilherme Polo | 55bdb8e | 2009-02-09 19:57:04 +0000 | [diff] [blame] | 12 | |
Guilherme Polo | bbb7efd | 2009-02-09 19:21:21 +0000 | [diff] [blame] | 13 | this_dir = os.path.dirname(os.path.abspath(__file__)) |
| 14 | lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir, |
| 15 | 'lib-tk', 'test')) |
| 16 | if lib_tk_test not in sys.path: |
| 17 | sys.path.append(lib_tk_test) |
| 18 | |
| 19 | import runtktests |
| 20 | |
| 21 | def test_main(enable_gui=False): |
| 22 | if enable_gui: |
| 23 | if test_support.use_resources is None: |
| 24 | test_support.use_resources = ['gui'] |
| 25 | elif 'gui' not in test_support.use_resources: |
| 26 | test_support.use_resources.append('gui') |
| 27 | |
| 28 | test_support.run_unittest( |
| 29 | *runtktests.get_tests(text=False, packages=['test_tkinter'])) |
| 30 | |
| 31 | if __name__ == '__main__': |
| 32 | test_main(enable_gui=True) |