blob: 495b4160f2c0291fbc5f95879280fd28bcf820f8 [file] [log] [blame]
Terry Jan Reedyd71244f2013-07-27 22:06:03 -04001import unittest
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
Terry Jan Reedyd71244f2013-07-27 22:06:03 -04004
5# Skip test if _thread or _tkinter wasn't built or idlelib was deleted.
Terry Jan Reedy09eb26f2013-07-21 20:13:24 -04006import_module('threading') # imported by idlelib.PyShell, imports _thread
Terry Jan Reedyd71244f2013-07-27 22:06:03 -04007tk = import_module('Tkinter') # imports _tkinter
Terry Jan Reedyb02a1b82013-05-30 18:24:28 -04008idletest = import_module('idlelib.idle_test')
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -04009
Terry Jan Reedy09eb26f2013-07-21 20:13:24 -040010# If buildbot improperly sets gui resource (#18365, #18441), remove it
11# so requires('gui') tests are skipped while non-gui tests still run.
Terry Jan Reedy16b10c62013-07-28 00:01:00 -040012# If there is a problem with Macs, see #18441, msg 193805
Terry Jan Reedy09eb26f2013-07-21 20:13:24 -040013if use_resources and 'gui' in use_resources:
14 try:
15 root = tk.Tk()
16 root.destroy()
Terry Jan Reedy44fad462014-02-27 18:47:23 -050017 del root
Terry Jan Reedy6fb6f8c2013-07-27 19:07:07 -040018 except tk.TclError:
19 while 'gui' in use_resources:
20 use_resources.remove('gui')
Terry Jan Reedy09eb26f2013-07-21 20:13:24 -040021
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -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
26
Terry Jan Reedya1ea8932013-11-03 23:37:54 -050027# pre-3.3 regrtest does not support the load_tests protocol. use test_main
28def test_main():
29 support.run_unittest(unittest.TestLoader().loadTestsFromModule(idletest))
30
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -040031if __name__ == '__main__':
Terry Jan Reedy1d142462013-06-29 18:22:02 -040032 # Until unittest supports resources, we emulate regrtest's -ugui
33 # so loaded tests run the same as if textually present here.
34 # If any Idle test ever needs another resource, add it to the list.
Terry Jan Reedy1d142462013-06-29 18:22:02 -040035 support.use_resources = ['gui'] # use_resources is initially None
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -040036 unittest.main(verbosity=2, exit=False)