blob: fc05be1870e02b096e56042cf1ffc660e5f90d19 [file] [log] [blame]
Terry Jan Reedy09eb26f2013-07-21 20:13:24 -04001# Skip test if _thread or _tkinter wasn't built or idlelib was deleted.
Terry Jan Reedy6fb6f8c2013-07-27 19:07:07 -04002from test import test_support as support
Terry Jan Reedy09eb26f2013-07-21 20:13:24 -04003from test.test_support import import_module, use_resources
4import_module('threading') # imported by idlelib.PyShell, imports _thread
5tk = import_module('Tkinter')
Terry Jan Reedyb02a1b82013-05-30 18:24:28 -04006idletest = import_module('idlelib.idle_test')
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -04007
Terry Jan Reedy09eb26f2013-07-21 20:13:24 -04008# If buildbot improperly sets gui resource (#18365, #18441), remove it
9# so requires('gui') tests are skipped while non-gui tests still run.
10if use_resources and 'gui' in use_resources:
11 try:
12 root = tk.Tk()
13 root.destroy()
Terry Jan Reedy6fb6f8c2013-07-27 19:07:07 -040014 except tk.TclError:
15 while 'gui' in use_resources:
16 use_resources.remove('gui')
Terry Jan Reedy09eb26f2013-07-21 20:13:24 -040017
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -040018# Without test_main present, regrtest.runtest_inner (line1219) calls
19# unittest.TestLoader().loadTestsFromModule(this_module) which calls
20# load_tests() if it finds it. (Unittest.main does the same.)
21load_tests = idletest.load_tests
22
23if __name__ == '__main__':
Terry Jan Reedy1d142462013-06-29 18:22:02 -040024 # Until unittest supports resources, we emulate regrtest's -ugui
25 # so loaded tests run the same as if textually present here.
26 # If any Idle test ever needs another resource, add it to the list.
Terry Jan Reedy1d142462013-06-29 18:22:02 -040027 support.use_resources = ['gui'] # use_resources is initially None
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -040028 import unittest
29 unittest.main(verbosity=2, exit=False)