Miss Islington (bot) | ec6a1ea | 2021-05-07 09:14:48 -0700 | [diff] [blame] | 1 | import sys |
Zachary Ware | 4baebfe | 2015-05-17 20:55:42 -0500 | [diff] [blame] | 2 | import unittest |
| 3 | from test import support |
Hai Shi | f7ba40b | 2020-06-25 18:38:51 +0800 | [diff] [blame] | 4 | from test.support import import_helper |
Zachary Ware | 4baebfe | 2015-05-17 20:55:42 -0500 | [diff] [blame] | 5 | |
| 6 | # Skip this test if the _tkinter module wasn't built. |
Hai Shi | f7ba40b | 2020-06-25 18:38:51 +0800 | [diff] [blame] | 7 | _tkinter = import_helper.import_module('_tkinter') |
Zachary Ware | 4baebfe | 2015-05-17 20:55:42 -0500 | [diff] [blame] | 8 | |
| 9 | # Skip test if tk cannot be initialized. |
| 10 | support.requires('gui') |
| 11 | |
Miss Islington (bot) | ec6a1ea | 2021-05-07 09:14:48 -0700 | [diff] [blame] | 12 | # Suppress the deprecation warning |
| 13 | tix = import_helper.import_module('tkinter.tix', deprecated=True) |
| 14 | from tkinter import TclError |
Zachary Ware | 4baebfe | 2015-05-17 20:55:42 -0500 | [diff] [blame] | 15 | |
| 16 | |
| 17 | class TestTix(unittest.TestCase): |
| 18 | |
| 19 | def setUp(self): |
| 20 | try: |
| 21 | self.root = tix.Tk() |
| 22 | except TclError: |
| 23 | if sys.platform.startswith('win'): |
| 24 | self.fail('Tix should always be available on Windows') |
| 25 | self.skipTest('Tix not available') |
| 26 | else: |
| 27 | self.addCleanup(self.root.destroy) |
| 28 | |
Miss Islington (bot) | c3eb3c1 | 2021-05-09 00:19:43 -0700 | [diff] [blame] | 29 | def test_tix_available(self): |
| 30 | # this test is just here to make setUp run |
| 31 | pass |
Zachary Ware | 4baebfe | 2015-05-17 20:55:42 -0500 | [diff] [blame] | 32 | |
| 33 | |
| 34 | if __name__ == '__main__': |
| 35 | unittest.main() |