From d5092ba8bbc4439098c4c7971e9b425a700773e6 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sun, 23 Aug 2026 01:57:16 -0400 Subject: [PATCH 1/3] gh-155648: Fix IDLE tests that cannot fail DD bug 26: test_autocomplete.py:241 passes when proper because `any([]) is True` is true. It would also pass if is small only had underscored words because the filter got reversed. Change logic and replace filter with generator expressions. test_editor.py:236 and test_configdialog.py:55 have empty tests ('pass'); comment them out. template.py:25 tests `True == True`; make another comparison. The template fix still might fail the bug scanner, but does not matter. It is not run, and might not be needed any longer. --- Lib/idlelib/idle_test/template.py | 2 +- Lib/idlelib/idle_test/test_autocomplete.py | 4 +- Lib/idlelib/idle_test/test_configdialog.py | 14 +++---- Lib/idlelib/idle_test/test_editor.py | 48 +++++++++++----------- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Lib/idlelib/idle_test/template.py b/Lib/idlelib/idle_test/template.py index 0a4bd8b8e981fc..81cead3fd09a41 100644 --- a/Lib/idlelib/idle_test/template.py +++ b/Lib/idlelib/idle_test/template.py @@ -22,7 +22,7 @@ def tearDownClass(cls): del cls.root def test_init(self): - self.assertTrue(True) + self.assertTrue(self) if __name__ == '__main__': diff --git a/Lib/idlelib/idle_test/test_autocomplete.py b/Lib/idlelib/idle_test/test_autocomplete.py index a811363c18d04e..ac3907e8e6fdd7 100644 --- a/Lib/idlelib/idle_test/test_autocomplete.py +++ b/Lib/idlelib/idle_test/test_autocomplete.py @@ -238,8 +238,8 @@ def test_fetch_completions(self): # Test attributes s, b = acp.fetch_completions('', ac.ATTRS) self.assertLess(len(small), len(large)) - self.assertTrue(all(filter(lambda x: x.startswith('_'), s))) - self.assertTrue(any(filter(lambda x: x.startswith('_'), b))) + self.assertFalse(any(x.startswith('_') for x in s)) + self.assertTrue(any(x.startswith('_') for x in b)) # Test smalll should respect to __all__. with patch.dict('__main__.__dict__', {'__all__': ['a', 'b']}): diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index 696a3b2f8f1bc2..6fd39d161e9ec5 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -50,13 +50,13 @@ def tearDownModule(): root = dialog = None -class ConfigDialogTest(unittest.TestCase): - - def test_deactivate_current_config(self): - pass - - def activate_config_changes(self): - pass +##class ConfigDialogTest(unittest.TestCase): +## +## def test_deactivate_current_config(self): +## pass +## +## def activate_config_changes(self): +## pass class ButtonTest(unittest.TestCase): diff --git a/Lib/idlelib/idle_test/test_editor.py b/Lib/idlelib/idle_test/test_editor.py index e28ee549f180aa..7661a4e72044b3 100644 --- a/Lib/idlelib/idle_test/test_editor.py +++ b/Lib/idlelib/idle_test/test_editor.py @@ -211,30 +211,30 @@ def test_searcher(self): self.assertEqual(actual_pair, expected_pair) -class RMenuTest(unittest.TestCase): - - @classmethod - def setUpClass(cls): - requires('gui') - cls.root = Tk() - cls.root.withdraw() - cls.window = Editor(root=cls.root) - - @classmethod - def tearDownClass(cls): - cls.window._close() - del cls.window - cls.root.update_idletasks() - for id in cls.root.after_info(): - cls.root.after_cancel(id) - cls.root.destroy() - del cls.root - - class DummyRMenu: - def tk_popup(x, y): pass - - def test_rclick(self): - pass +##class RMenuTest(unittest.TestCase): +## +## @classmethod +## def setUpClass(cls): +## requires('gui') +## cls.root = Tk() +## cls.root.withdraw() +## cls.window = Editor(root=cls.root) +## +## @classmethod +## def tearDownClass(cls): +## cls.window._close() +## del cls.window +## cls.root.update_idletasks() +## for id in cls.root.after_info(): +## cls.root.after_cancel(id) +## cls.root.destroy() +## del cls.root +## +## class DummyRMenu: +## def tk_popup(x, y): pass +## +## def test_rclick(self): +## pass # Comment out because cannot fail; gh-155648. if __name__ == '__main__': From 5160ed032151cb42202c8b76d91c864539b44ada Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sun, 23 Aug 2026 15:46:15 -0400 Subject: [PATCH 2/3] Respond to comments. --- Lib/idlelib/idle_test/template.py | 3 +- Lib/idlelib/idle_test/test_autocomplete.py | 4 +- Lib/idlelib/idle_test/test_configdialog.py | 15 +++---- Lib/idlelib/idle_test/test_editor.py | 49 +++++++++++----------- 4 files changed, 37 insertions(+), 34 deletions(-) diff --git a/Lib/idlelib/idle_test/template.py b/Lib/idlelib/idle_test/template.py index 81cead3fd09a41..7c3df6ba8fbce3 100644 --- a/Lib/idlelib/idle_test/template.py +++ b/Lib/idlelib/idle_test/template.py @@ -21,8 +21,9 @@ def tearDownClass(cls): cls.root.destroy() del cls.root + @unittest.skip('Dummy test') def test_init(self): - self.assertTrue(self) + self.assertTrue(True) if __name__ == '__main__': diff --git a/Lib/idlelib/idle_test/test_autocomplete.py b/Lib/idlelib/idle_test/test_autocomplete.py index ac3907e8e6fdd7..e7019f7928543f 100644 --- a/Lib/idlelib/idle_test/test_autocomplete.py +++ b/Lib/idlelib/idle_test/test_autocomplete.py @@ -238,8 +238,8 @@ def test_fetch_completions(self): # Test attributes s, b = acp.fetch_completions('', ac.ATTRS) self.assertLess(len(small), len(large)) - self.assertFalse(any(x.startswith('_') for x in s)) - self.assertTrue(any(x.startswith('_') for x in b)) + self.assertFalse(any(x[0] == '_' for x in s)) + self.assertTrue(any(x[0] == '_' for x in b)) # Test smalll should respect to __all__. with patch.dict('__main__.__dict__', {'__all__': ['a', 'b']}): diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index 6fd39d161e9ec5..f3e1c785a92674 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -50,13 +50,14 @@ def tearDownModule(): root = dialog = None -##class ConfigDialogTest(unittest.TestCase): -## -## def test_deactivate_current_config(self): -## pass -## -## def activate_config_changes(self): -## pass +@unittest.skip('Empty tests') +class ConfigDialogTest(unittest.TestCase): + + def test_deactivate_current_config(self): + pass + + def activate_config_changes(self): + pass class ButtonTest(unittest.TestCase): diff --git a/Lib/idlelib/idle_test/test_editor.py b/Lib/idlelib/idle_test/test_editor.py index 7661a4e72044b3..1fcea4f1eb0d6a 100644 --- a/Lib/idlelib/idle_test/test_editor.py +++ b/Lib/idlelib/idle_test/test_editor.py @@ -211,30 +211,31 @@ def test_searcher(self): self.assertEqual(actual_pair, expected_pair) -##class RMenuTest(unittest.TestCase): -## -## @classmethod -## def setUpClass(cls): -## requires('gui') -## cls.root = Tk() -## cls.root.withdraw() -## cls.window = Editor(root=cls.root) -## -## @classmethod -## def tearDownClass(cls): -## cls.window._close() -## del cls.window -## cls.root.update_idletasks() -## for id in cls.root.after_info(): -## cls.root.after_cancel(id) -## cls.root.destroy() -## del cls.root -## -## class DummyRMenu: -## def tk_popup(x, y): pass -## -## def test_rclick(self): -## pass # Comment out because cannot fail; gh-155648. +@unittest.skip('Empty test') +class RMenuTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + requires('gui') + cls.root = Tk() + cls.root.withdraw() + cls.window = Editor(root=cls.root) + + @classmethod + def tearDownClass(cls): + cls.window._close() + del cls.window + cls.root.update_idletasks() + for id in cls.root.after_info(): + cls.root.after_cancel(id) + cls.root.destroy() + del cls.root + + class DummyRMenu: + def tk_popup(x, y): pass + + def test_rclick(self): + pass if __name__ == '__main__': From e4614b7399376dc3824172b78afee810fdc4c34f Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sun, 23 Aug 2026 17:58:09 -0400 Subject: [PATCH 3/3] Signed-off-by: Terry Jan Reedy --- Lib/idlelib/idle_test/test_autocomplete.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Lib/idlelib/idle_test/test_autocomplete.py b/Lib/idlelib/idle_test/test_autocomplete.py index e7019f7928543f..88af3efc35bbd1 100644 --- a/Lib/idlelib/idle_test/test_autocomplete.py +++ b/Lib/idlelib/idle_test/test_autocomplete.py @@ -230,16 +230,14 @@ def test_fetch_completions(self): # For file completion, a large list containing all files in the path, # and a small list containing files that do not start with '.'. acp = self.autocomplete - small, large = acp.fetch_completions( - '', ac.ATTRS) - if hasattr(__main__, '__file__') and __main__.__file__ != ac.__file__: - self.assertNotIn('AutoComplete', small) # See issue 36405. - # Test attributes - s, b = acp.fetch_completions('', ac.ATTRS) - self.assertLess(len(small), len(large)) - self.assertFalse(any(x[0] == '_' for x in s)) - self.assertTrue(any(x[0] == '_' for x in b)) + # Test current module (what='') attributes. + small, large = acp.fetch_completions('', ac.ATTRS) + if hasattr(__main__, '__file__') and __main__.__file__ != ac.__file__: + self.assertNotIn('AutoComplete', small) # See gh-80586. + self.assertLess(len(small), len(large)) # Not equal + self.assertFalse(any(a[:1] == '_' for a in small)) + self.assertTrue(any(a[:1] == '_' for a in large)) # Test smalll should respect to __all__. with patch.dict('__main__.__dict__', {'__all__': ['a', 'b']}):