diff --git a/Lib/idlelib/idle_test/test_codecontext.py b/Lib/idlelib/idle_test/test_codecontext.py index 3f070da022384ec..13465d5c98c4872 100644 --- a/Lib/idlelib/idle_test/test_codecontext.py +++ b/Lib/idlelib/idle_test/test_codecontext.py @@ -60,6 +60,8 @@ def setUpClass(cls): frame = cls.frame = Frame(root) text = cls.text = Text(frame) text.insert('1.0', code_sample) + # Make the text longer than the visible height, so that it can scroll. + text.insert('end', '\n' * (int(text['height']) + 2)) # Need to pack for creation of code context text widget. frame.pack(side='left', fill='both', expand=1) text.grid(row=1, column=1, sticky=NSEW) diff --git a/Lib/idlelib/idle_test/test_sidebar.py b/Lib/idlelib/idle_test/test_sidebar.py index 848f12a5d7c1850..6901413c416afda 100644 --- a/Lib/idlelib/idle_test/test_sidebar.py +++ b/Lib/idlelib/idle_test/test_sidebar.py @@ -317,6 +317,10 @@ def test_drag_selection_up(self): self.assertEqual(self.get_selection(), ('2.0', '5.0')) def test_scroll(self): + # Synchronized scrolling needs the geometry of mapped widgets. + self.root.deiconify() + self.addCleanup(self.root.withdraw) + self.linenumber.show_sidebar() self.text.insert('1.0', 'line\n' * 100) self.root.update() diff --git a/Lib/test/test_tkinter/test_text.py b/Lib/test/test_tkinter/test_text.py index 27423006a7e71b8..c28f4e3f130d7af 100644 --- a/Lib/test/test_tkinter/test_text.py +++ b/Lib/test/test_tkinter/test_text.py @@ -774,10 +774,16 @@ def test_count(self): self.assertRaises(TclError, text.count, '1.0', 'end', 'spam') self.assertRaises(TclError, text.count, '1.0', 'end', '-lines') - self.assertIsInstance(text.count('1.3', '1.5', 'ypixels', return_ints=True), int) - self.assertIsInstance(text.count('1.3', '1.5', 'ypixels'), tuple) - self.assertIsInstance(text.count('1.3', '1.5', 'update', 'ypixels', return_ints=True), int) - self.assertIsInstance(text.count('1.3', '1.5', 'update', 'ypixels'), int) + # The ypixels counts depend on the widget geometry. + text.update() + + # Indices on the same display line have zero vertical distance. + self.assertEqual(text.count('1.3', '1.5', 'ypixels', return_ints=True), 0) + self.assertIsNone(text.count('1.3', '1.5', 'ypixels')) + self.assertIsInstance(text.count('1.3', '2.5', 'ypixels', return_ints=True), int) + self.assertIsInstance(text.count('1.3', '2.5', 'ypixels'), tuple) + self.assertIsInstance(text.count('1.3', '2.5', 'update', 'ypixels', return_ints=True), int) + self.assertIsInstance(text.count('1.3', '2.5', 'update', 'ypixels'), int) self.assertEqual(text.count('1.3', '1.3', 'update', 'ypixels', return_ints=True), 0) self.assertEqual(text.count('1.3', '1.3', 'update', 'ypixels'), None) self.assertEqual(text.count('1.3', '1.5', 'update', 'indices', return_ints=True), 2)