From: Serhiy Storchaka Date: Wed, 24 Jun 2026 21:36:57 +0000 (+0300) Subject: gh-152093: Fix test_tk_caret() on macOS (GH-152115) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b41dc4ac6354dd563258a9766325496c3b2e82e1;p=thirdparty%2FPython%2Fcpython.git gh-152093: Fix test_tk_caret() on macOS (GH-152115) macOS records the caret only for the key window, so the query reads back zeros instead of the values set in the test. Co-authored-by: Claude Opus 4.8 --- diff --git a/Lib/test/test_tkinter/test_misc.py b/Lib/test/test_tkinter/test_misc.py index cfd3090e46b1..98af4d822dad 100644 --- a/Lib/test/test_tkinter/test_misc.py +++ b/Lib/test/test_tkinter/test_misc.py @@ -485,7 +485,11 @@ class MiscTest(AbstractTkTest, unittest.TestCase): def test_tk_caret(self): self.assertIsNone(self.root.tk_caret(x=5, y=10, height=20)) caret = self.root.tk_caret() - self.assertEqual(caret, {'x': 5, 'y': 10, 'height': 20}) + if self.root._windowingsystem == 'aqua': + # macOS records the caret only for the key window. + self.assertEqual(set(caret), {'x', 'y', 'height'}) + else: + self.assertEqual(caret, {'x': 5, 'y': 10, 'height': 20}) def test_tk_scaling(self): old = self.root.tk_scaling()