blob: 07f45c6999ceb760d55f045ee0ef1f3dd03d4f6c [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 Reedy6fb6f8c2013-07-27 19:07:07 -040017 except tk.TclError:
18 while 'gui' in use_resources:
19 use_resources.remove('gui')
Terry Jan Reedy09eb26f2013-07-21 20:13:24 -040020
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -040021# Without test_main present, regrtest.runtest_inner (line1219) calls
22# unittest.TestLoader().loadTestsFromModule(this_module) which calls
23# load_tests() if it finds it. (Unittest.main does the same.)
24load_tests = idletest.load_tests
25
Terry Jan Reedya1ea8932013-11-03 23:37:54 -050026# pre-3.3 regrtest does not support the load_tests protocol. use test_main
27def test_main():
28 support.run_unittest(unittest.TestLoader().loadTestsFromModule(idletest))
29
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -040030if __name__ == '__main__':
Terry Jan Reedy1d142462013-06-29 18:22:02 -040031 # Until unittest supports resources, we emulate regrtest's -ugui
32 # so loaded tests run the same as if textually present here.
33 # If any Idle test ever needs another resource, add it to the list.
Terry Jan Reedy1d142462013-06-29 18:22:02 -040034 support.use_resources = ['gui'] # use_resources is initially None
Terry Jan Reedyb8fd9ca2013-05-30 14:47:33 -040035 unittest.main(verbosity=2, exit=False)