]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-152093: Fix test_tk_caret() on macOS (GH-152115)
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 24 Jun 2026 21:36:57 +0000 (00:36 +0300)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2026 21:36:57 +0000 (00:36 +0300)
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 <noreply@anthropic.com>
Lib/test/test_tkinter/test_misc.py

index cfd3090e46b1abfb5b42b9917d590d6f585923bf..98af4d822dadc43d33bff65756d91d996a9a9ecb 100644 (file)
@@ -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()