Skip to content

Commit d5092ba

Browse files
committed
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.
1 parent b062727 commit d5092ba

4 files changed

Lines changed: 34 additions & 34 deletions

File tree

Lib/idlelib/idle_test/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def tearDownClass(cls):
2222
del cls.root
2323

2424
def test_init(self):
25-
self.assertTrue(True)
25+
self.assertTrue(self)
2626

2727

2828
if __name__ == '__main__':

Lib/idlelib/idle_test/test_autocomplete.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ def test_fetch_completions(self):
238238
# Test attributes
239239
s, b = acp.fetch_completions('', ac.ATTRS)
240240
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)))
241+
self.assertFalse(any(x.startswith('_') for x in s))
242+
self.assertTrue(any(x.startswith('_') for x in b))
243243

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

Lib/idlelib/idle_test/test_configdialog.py

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

5252

53-
class ConfigDialogTest(unittest.TestCase):
54-
55-
def test_deactivate_current_config(self):
56-
pass
57-
58-
def activate_config_changes(self):
59-
pass
53+
##class ConfigDialogTest(unittest.TestCase):
54+
##
55+
## def test_deactivate_current_config(self):
56+
## pass
57+
##
58+
## def activate_config_changes(self):
59+
## pass
6060

6161

6262
class ButtonTest(unittest.TestCase):

Lib/idlelib/idle_test/test_editor.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -211,30 +211,30 @@ def test_searcher(self):
211211
self.assertEqual(actual_pair, expected_pair)
212212

213213

214-
class RMenuTest(unittest.TestCase):
215-
216-
@classmethod
217-
def setUpClass(cls):
218-
requires('gui')
219-
cls.root = Tk()
220-
cls.root.withdraw()
221-
cls.window = Editor(root=cls.root)
222-
223-
@classmethod
224-
def tearDownClass(cls):
225-
cls.window._close()
226-
del cls.window
227-
cls.root.update_idletasks()
228-
for id in cls.root.after_info():
229-
cls.root.after_cancel(id)
230-
cls.root.destroy()
231-
del cls.root
232-
233-
class DummyRMenu:
234-
def tk_popup(x, y): pass
235-
236-
def test_rclick(self):
237-
pass
214+
##class RMenuTest(unittest.TestCase):
215+
##
216+
## @classmethod
217+
## def setUpClass(cls):
218+
## requires('gui')
219+
## cls.root = Tk()
220+
## cls.root.withdraw()
221+
## cls.window = Editor(root=cls.root)
222+
##
223+
## @classmethod
224+
## def tearDownClass(cls):
225+
## cls.window._close()
226+
## del cls.window
227+
## cls.root.update_idletasks()
228+
## for id in cls.root.after_info():
229+
## cls.root.after_cancel(id)
230+
## cls.root.destroy()
231+
## del cls.root
232+
##
233+
## class DummyRMenu:
234+
## def tk_popup(x, y): pass
235+
##
236+
## def test_rclick(self):
237+
## pass # Comment out because cannot fail; gh-155648.
238238

239239

240240
if __name__ == '__main__':

0 commit comments

Comments
 (0)