|
1 | 1 | import unittest |
2 | 2 | from test.support import import_module |
3 | 3 |
|
4 | | -# Skip test if _thread or _tkinter wasn't built, or idlelib is missing, |
5 | | -# or if tcl/tk version before 8.5, which is needed for ttk widgets. |
6 | | - |
| 4 | +# Skip test if _thread or _tkinter wasn't built, if idlelib is missing, |
| 5 | +# or if tcl/tk is not the 8.5+ needed for ttk widgets. |
7 | 6 | import_module('threading') # imported by PyShell, imports _thread |
8 | 7 | tk = import_module('tkinter') # imports _tkinter |
9 | 8 | if tk.TkVersion < 8.5: |
10 | 9 | raise unittest.SkipTest("IDLE requires tk 8.5 or later.") |
11 | | -tk.NoDefaultRoot() |
12 | 10 | idlelib = import_module('idlelib') |
13 | | -idlelib.testing = True # Avoid locale-changed test error |
14 | 11 |
|
15 | | -# Without test_main present, test.libregrtest.runtest.runtest_inner |
16 | | -# calls (line 173) unittest.TestLoader().loadTestsFromModule(module) |
17 | | -# which calls load_tests() if it finds it. (Unittest.main does the same.) |
| 12 | +# Before test imports, tell IDLE to avoid changing the environment. |
| 13 | +idlelib.testing = True |
| 14 | + |
| 15 | +# unittest.main and test.libregrtest.runtest.runtest_inner |
| 16 | +# call load_tests, when present, to discover tests to run. |
18 | 17 | from idlelib.idle_test import load_tests |
19 | 18 |
|
20 | 19 | if __name__ == '__main__': |
21 | | - unittest.main(verbosity=2, exit=False) |
| 20 | + tk.NoDefaultRoot() |
| 21 | + unittest.main(exit=False) |
22 | 22 | tk._support_default_root = 1 |
23 | 23 | tk._default_root = None |
0 commit comments