blob: 7770ee59e42654c28ea61661bfae48e87ae3e499 [file] [log] [blame]
Terry Jan Reedy725d9dd2013-07-28 00:00:20 -04001import unittest
2from test import support
3from test.support import import_module, use_resources
4
5# Skip test if _thread or _tkinter wasn't built or idlelib was deleted.
Terry Jan Reedyeb4c9c72013-05-28 22:21:53 -04006import_module('threading') # imported by PyShell, imports _thread
Terry Jan Reedy725d9dd2013-07-28 00:00:20 -04007tk = import_module('tkinter') # imports _tkinter
Terry Jan Reedyeb4c9c72013-05-28 22:21:53 -04008idletest = import_module('idlelib.idle_test')
Terry Jan Reedydb4e5c52013-05-27 21:32:03 -04009
Terry Jan Reedy725d9dd2013-07-28 00:00:20 -040010# If buildbot improperly sets gui resource (#18365, #18441), remove it
11# so requires('gui') tests are skipped while non-gui tests still run.
12# If there is a problem with Macs, see #18441, msg 193805
13if use_resources and 'gui' in use_resources:
14 try:
15 root = tk.Tk()
16 root.destroy()
Terry Jan Reedy9db1ab82014-02-27 18:47:49 -050017 del root
Terry Jan Reedy725d9dd2013-07-28 00:00:20 -040018 except tk.TclError:
19 while 'gui' in use_resources:
20 use_resources.remove('gui')
21
Terry Jan Reedyeb4c9c72013-05-28 22:21:53 -040022# Without test_main present, regrtest.runtest_inner (line1219) calls
23# unittest.TestLoader().loadTestsFromModule(this_module) which calls
24# load_tests() if it finds it. (Unittest.main does the same.)
25load_tests = idletest.load_tests
Terry Jan Reedydb4e5c52013-05-27 21:32:03 -040026
27if __name__ == '__main__':
Terry Jan Reedye4e530e2013-06-29 18:22:02 -040028 # Until unittest supports resources, we emulate regrtest's -ugui
29 # so loaded tests run the same as if textually present here.
30 # If any Idle test ever needs another resource, add it to the list.
Terry Jan Reedye4e530e2013-06-29 18:22:02 -040031 support.use_resources = ['gui'] # use_resources is initially None
Terry Jan Reedydb4e5c52013-05-27 21:32:03 -040032 unittest.main(verbosity=2, exit=False)