Skip to content

gh-155648: Fix IDLE tests that cannot fail - #156257

Open
terryjreedy wants to merge 3 commits into
python:mainfrom
terryjreedy:ddbug26
Open

gh-155648: Fix IDLE tests that cannot fail#156257
terryjreedy wants to merge 3 commits into
python:mainfrom
terryjreedy:ddbug26

Conversation

@terryjreedy

@terryjreedy terryjreedy commented Aug 23, 2026

Copy link
Copy Markdown
Member

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.

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.
@terryjreedy terryjreedy added skip news topic-IDLE needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 23, 2026
Comment on lines +241 to +242
self.assertFalse(any(x.startswith('_') for x in s))
self.assertTrue(any(x.startswith('_') for x in b))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it the same?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first test is that the small list has no underscore words. The buggy previous test would have also passed if it has all underscore words, perhaps from the condition in the filter being flipped.

The second test is that the big list has at least one underscore word. There are many, but not fixed. Hopefully, it has all there should be and at least 1 means not all were removed.

I am replacing x.startswith('_') with x[0] == '_'. None of the reasons for 'startswith' apply here.

Comment thread Lib/idlelib/idle_test/test_editor.py Outdated

def test_rclick(self):
pass
##class RMenuTest(unittest.TestCase):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be a pain to uncomment it all beck when real tests will be added. If you want to make the skip more explicit, you can use @unittest.skip().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a pain in the IDLE editor, but you are right. Changed to 'skip', which your PR can easily be modified to delete.

Comment thread Lib/idlelib/idle_test/template.py Outdated

def test_init(self):
self.assertTrue(True)
self.assertTrue(self)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a template file. It is not executed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know that it is excluded from the IDLE test suite, but the bug scanner does not. And it does not know that the purpose of executing the file, which I have done, is to verify the syntax of everything else in the file and that the test is needed to make setUpClass and tearDownClass run. Adding unittest.skip solves that purpose and should satisfy the scanner.

@serhiy-storchaka

Copy link
Copy Markdown
Member

See #156260 which implements the tests instead of commenting them out.

@terryjreedy

Copy link
Copy Markdown
Member Author

I made a change in each file. Please re-review. I would like to merge this now as a minimal fix, and include 3.15 in the backports. I looked at the +300 lines of real tests and would like to defer them until 3.15 is unlocked.

Comment on lines 233 to 234

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between these lines...

@@ -238,8 +238,8 @@ def test_fetch_completions(self):
# Test attributes
s, b = acp.fetch_completions('', ac.ATTRS)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and this?

@terryjreedy terryjreedy Aug 23, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names assigned to by the duplicate calls added for different tests added at different times.
Since you asked, and these surround the buggy line, I added the cleanup. Much clearer now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news topic-IDLE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants