Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 725d9dd

Browse files
committed
Issue #18441: Make test.support.requires('gui') skip when it should.
1 parent ae6d05b commit 725d9dd

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

Lib/test/test_idle.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
# Skip test if _tkinter or _thread wasn't built or idlelib was deleted.
2-
from test.support import import_module
3-
import_module('tkinter')
1+
import unittest
2+
from test import support
3+
from test.support import import_module, use_resources
4+
5+
# Skip test if _thread or _tkinter wasn't built or idlelib was deleted.
46
import_module('threading') # imported by PyShell, imports _thread
7+
tk = import_module('tkinter') # imports _tkinter
58
idletest = import_module('idlelib.idle_test')
69

10+
# 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
13+
if use_resources and 'gui' in use_resources:
14+
try:
15+
root = tk.Tk()
16+
root.destroy()
17+
except tk.TclError:
18+
while 'gui' in use_resources:
19+
use_resources.remove('gui')
20+
721
# Without test_main present, regrtest.runtest_inner (line1219) calls
822
# unittest.TestLoader().loadTestsFromModule(this_module) which calls
923
# load_tests() if it finds it. (Unittest.main does the same.)
@@ -13,7 +27,5 @@
1327
# Until unittest supports resources, we emulate regrtest's -ugui
1428
# so loaded tests run the same as if textually present here.
1529
# If any Idle test ever needs another resource, add it to the list.
16-
from test import support
1730
support.use_resources = ['gui'] # use_resources is initially None
18-
import unittest
1931
unittest.main(verbosity=2, exit=False)

0 commit comments

Comments
 (0)