Skip to content

Commit 0dd5cee

Browse files
gh-151678: Skip the grab_set_global error path off X11
Grabbing a non-viewable window raises "grab failed" only on X11; on Aqua and Windows it would instead grab the whole display. Keep testing the portable TypeError path everywhere and skip only that subtest elsewhere. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent cafc8ae commit 0dd5cee

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Lib/test/test_tkinter/test_misc.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,14 @@ def handler(offset, length):
490490
def test_grab_set_global(self):
491491
# A successful global grab directs all events on the display to this
492492
# application, so only the error paths are tested here.
493-
f = tkinter.Frame(self.root) # not yet viewable
494-
self.assertRaisesRegex(TclError, 'grab failed', f.grab_set_global)
495493
self.assertRaises(TypeError, self.root.grab_set_global, 'extra')
494+
with self.subTest('non-viewable window'):
495+
if self.root._windowingsystem != 'x11':
496+
# Grabbing a non-viewable window fails only on X11; elsewhere
497+
# it would actually grab the whole display.
498+
self.skipTest('only X11 fails the grab')
499+
f = tkinter.Frame(self.root) # not yet viewable
500+
self.assertRaisesRegex(TclError, 'grab failed', f.grab_set_global)
496501

497502
def test_send(self):
498503
if self.root._windowingsystem != 'x11':

0 commit comments

Comments
 (0)