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