Skip to content

Commit 7cc0932

Browse files
[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 ee1da7e) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parent bc596bd commit 7cc0932

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

Lib/idlelib/idle_test/template.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def tearDownClass(cls):
2121
cls.root.destroy()
2222
del cls.root
2323

24+
@unittest.skip('Dummy test')
2425
def test_init(self):
2526
self.assertTrue(True)
2627

Lib/idlelib/idle_test/test_autocomplete.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,14 @@ def test_fetch_completions(self):
230230
# For file completion, a large list containing all files in the path,
231231
# and a small list containing files that do not start with '.'.
232232
acp = self.autocomplete
233-
small, large = acp.fetch_completions(
234-
'', ac.ATTRS)
235-
if hasattr(__main__, '__file__') and __main__.__file__ != ac.__file__:
236-
self.assertNotIn('AutoComplete', small) # See issue 36405.
237233

238-
# Test attributes
239-
s, b = acp.fetch_completions('', ac.ATTRS)
240-
self.assertLess(len(small), len(large))
241-
self.assertTrue(all(filter(lambda x: x.startswith('_'), s)))
242-
self.assertTrue(any(filter(lambda x: x.startswith('_'), b)))
234+
# Test current module (what='') attributes.
235+
small, large = acp.fetch_completions('', ac.ATTRS)
236+
if hasattr(__main__, '__file__') and __main__.__file__ != ac.__file__:
237+
self.assertNotIn('AutoComplete', small) # See gh-80586.
238+
self.assertLess(len(small), len(large)) # Not equal
239+
self.assertFalse(any(a[:1] == '_' for a in small))
240+
self.assertTrue(any(a[:1] == '_' for a in large))
243241

244242
# Test smalll should respect to __all__.
245243
with patch.dict('__main__.__dict__', {'__all__': ['a', 'b']}):

Lib/idlelib/idle_test/test_configdialog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def tearDownModule():
5050
root = dialog = None
5151

5252

53+
@unittest.skip('Empty tests')
5354
class ConfigDialogTest(unittest.TestCase):
5455

5556
def test_deactivate_current_config(self):

Lib/idlelib/idle_test/test_editor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def test_searcher(self):
211211
self.assertEqual(actual_pair, expected_pair)
212212

213213

214+
@unittest.skip('Empty test')
214215
class RMenuTest(unittest.TestCase):
215216

216217
@classmethod

0 commit comments

Comments
 (0)