[3.14] gh-155648: Fix IDLE tests that cannot fail (GH-156257) (#156316)
terryjreedy <[email protected]>
| Newsgroups | gmane.comp.python.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://github.com/python/cpython/commit/7cc0932332f1fe680bb370c314871c0a884293d0 commit: 7cc0932332f1fe680bb370c314871c0a884293d0 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: terryjreedy <[email protected]> date: 2026-08-24T14:49:42Z summary: [3.14] gh-155648: Fix IDLE tests that cannot fail (GH-156257) (#156316) gh-155648: Fix IDLE tests that cannot fail (GH-156257) test_autocomplete.py:241 passes when proper because any([]) is True is true. It would also pass if small only had underscored words because the filter got reversed. Change logic and replace filter with generator expression using slice instead of startswith. Change line 242 to match. test_editor.py:236 and test_configdialog.py:55 have empty tests ('pass'); skip them for now. PR-GH-156260 add real tests. template.py:25 tests True == True; skip it. With this, the bug scanner should be satisfied while allowing setUpClass and tearDownClass to run and be verified. Remove duplicate and confusing fetch_completions call. (cherry picked from commit ee1da7ec8e939a998d5ecf2c749d45eb8f7714e4) Co-authored-by: Terry Jan Reedy <[email protected]> files: M Lib/idlelib/idle_test/template.py M Lib/idlelib/idle_test/test_autocomplete.py M Lib/idlelib/idle_test/test_configdialog.py M Lib/idlelib/idle_test/test_editor.py diff --git a/Lib/idlelib/idle_test/template.py b/Lib/idlelib/idle_test/template.py index 0a4bd8b8e981fc7..7c3df6ba8fbce38 100644 --- a/Lib/idlelib/idle_test/template.py +++ b/Lib/idlelib/idle_test/template.py @@ -21,6 +21,7 @@ def tearDownClass(cls): cls.root.destroy() del cls.root + @unittest.skip('Dummy test') def test_init(self): self.assertTrue(True) diff --git a/Lib/idlelib/idle_test/test_autocomplete.py b/Lib/idlelib/idle_test/test_autocomplete.py index a811363c18d04e5..88af3efc35bbd18 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.assertTrue(all(filter(lambda x: x.startswith('_'), s))) - self.assertTrue(any(filter(lambda x: x.startswith('_'), 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']}): diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index 696a3b2f8f1bc23..f3e1c785a92674c 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -50,6 +50,7 @@ def tearDownModule(): root = dialog = None [email protected]('Empty tests') class ConfigDialogTest(unittest.TestCase): def test_deactivate_current_config(self): diff --git a/Lib/idlelib/idle_test/test_editor.py b/Lib/idlelib/idle_test/test_editor.py index e28ee549f180aa0..1fcea4f1eb0d6a0 100644 --- a/Lib/idlelib/idle_test/test_editor.py +++ b/Lib/idlelib/idle_test/test_editor.py @@ -211,6 +211,7 @@ def test_searcher(self): self.assertEqual(actual_pair, expected_pair) [email protected]('Empty test') class RMenuTest(unittest.TestCase): @classmethod _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]