gh-155648: Fix IDLE tests that cannot fail - #156257
Conversation
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.
| self.assertFalse(any(x.startswith('_') for x in s)) | ||
| self.assertTrue(any(x.startswith('_') for x in b)) |
There was a problem hiding this comment.
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.
|
|
||
| def test_rclick(self): | ||
| pass | ||
| ##class RMenuTest(unittest.TestCase): |
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
Not a pain in the IDLE editor, but you are right. Changed to 'skip', which your PR can easily be modified to delete.
|
|
||
| def test_init(self): | ||
| self.assertTrue(True) | ||
| self.assertTrue(self) |
There was a problem hiding this comment.
This is a template file. It is not executed.
There was a problem hiding this comment.
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.
|
See #156260 which implements the tests instead of commenting them out. |
|
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. |
There was a problem hiding this comment.
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) | |||
There was a problem hiding this comment.
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.
DD bug 26:
test_autocomplete.py:241 passes when proper because
any([]) is Trueis 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.