Skip to content

gh-155648: Write the empty and placeholder IDLE tests - #156260

Merged
terryjreedy merged 11 commits into
python:mainfrom
serhiy-storchaka:idle-test-placeholders
Sep 9, 2026
Merged

gh-155648: Write the empty and placeholder IDLE tests#156260
terryjreedy merged 11 commits into
python:mainfrom
serhiy-storchaka:idle-test-placeholders

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 23, 2026

Copy link
Copy Markdown
Member

Several tests in idlelib/idle_test are empty stubs or placeholders that cannot fail. Write them instead of removing them.

  • test_editor.RMenuTest was added in bpo-39885: IDLE: Leave selection when right click within #18951, which fixed right-clicking inside a selection, with the note that an automated test should follow. Its DummyRMenu class is used now to test right_menu_event(), together with the rmenu_check_*() methods that supply the menu entry states.
  • test_configdialog.ConfigDialogTest was left with two empty stubs in bpo-30780: Add IDLE configdialog tests #3592, named after the two ConfigDialog methods which the button tests only check to be called. They are tested with a fake parent whose instance dictionary contains an autospecced EditorWindow.
  • test_configdialog.ExtPageTest was added empty, with a commented out "Nothing here yet TODO" skip, when ExtPage was factored out in bpo-40468: Factor out class ExtPage in idlelib.configdialog #26618. The extensions page is the only configuration page without tests.
  • test_grep.Default_commandTest was left empty in 2013 because GrepDialog.default_command() imports OutputWindow when called. The import cannot be moved to the top of the module due to an import loop, but the imported class can be replaced with a mock.
  • test_config.ChangesTest.test_save_default never called save_all(), so it tested nothing. The test for the Save() calls asked for by the following TODO comment is added too.
  • test_config.IdleConfTest.test_get_current_keyset only tested the non-darwin branch, because the default key sets no longer contain Alt keys. An extension binding with an Alt key is added, so that its replacement with Option can be tested.
  • template.py lost the from idlelib import zzdummy line in gh-151428: Remove unused imports from stdlib #151478 as an unused import, but idle_test/README.txt instructs the user to replace zzdummy with the name of the module under test. A Ruff per-file ignore keeps it now.

Each new test was checked to fail when the corresponding code is broken.

The first two items are an alternative to the now merged #156257, which skipped these two stubs as empty. Its skips are removed here, because the tests are written. Its other changes, the vacuous assertion in test_autocomplete and the skipped dummy test in template.py, are left as they are.

serhiy-storchaka and others added 3 commits August 23, 2026 10:23
It was removed as an unused import in pythonGH-151478, but template.py is a
skeleton for creating new IDLE test files, and idle_test/README.txt
instructs the user to replace 'zzdummy' with the name of the module
under test.  Add a Ruff per-file ignore to keep it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…m out

test_editor.RMenuTest was added in pythonGH-18951, which fixed right-clicking
inside a selection, with the note that an automated test should follow.
Use the DummyRMenu class left there to test right_menu_event(), and test
the rmenu_check_*() methods that supply the menu entry states.

test_configdialog.ConfigDialogTest was left with two empty stubs in
pythonGH-3592, named after the two ConfigDialog methods which the button tests
only check to be called.  Test them with a fake parent whose instance
dictionary contains an autospecced EditorWindow.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test_configdialog.ExtPageTest was added empty, with a commented-out
  "Nothing here yet TODO" skip, when ExtPage was factored out of
  ConfigDialog in pythonGH-26618.  Test load_extensions(), extension_selected(),
  set_extension_value() and save_all_changed_extensions().

* test_grep.Default_commandTest was left empty in 2013 because
  GrepDialog.default_command() imports OutputWindow when called, and the
  import cannot be moved to the top of the module due to an import loop.
  Replace the imported class with a mock instead of moving the import.

* test_config.ChangesTest.test_save_default never called save_all(), so
  it tested nothing.  Add the missing assertions, and add the test for
  the Save() calls that the following TODO comment asked for.

* test_config.IdleConfTest.test_get_current_keyset only tested the
  non-darwin branch, because the default key sets no longer contain Alt
  keys.  Add an extension binding with an Alt key, so that its
  replacement with Option can be tested.  Remove the stale commented-out
  test in test_get_extension_keys, which used the ZoomHeight extension.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Text.bbox() returns None while the window is not mapped, as on Windows,
where the root window of the test is withdrawn.  Ask the widget for the
index of the clicked character instead of computing the coordinates of
a known index.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
terryjreedy added a commit that referenced this pull request Aug 24, 2026
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-#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.
serhiy-storchaka and others added 2 commits August 24, 2026 17:37
RMenuTest and ConfigDialogTest were skipped as empty in pythonGH-156257.
They are no longer empty.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
terryjreedy added a commit that referenced this pull request Aug 24, 2026
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>
terryjreedy added a commit that referenced this pull request Aug 24, 2026
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>
@AlexWaygood
AlexWaygood removed their request for review August 24, 2026 14:52
@terryjreedy terryjreedy added 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 24, 2026
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Aug 27, 2026
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-python#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.
Comment thread Lib/idlelib/idle_test/template.py Outdated
Comment thread Lib/.ruff.toml Outdated
Name the loop variable after what it holds in test_save_all_saves_files,
say what RMenuTest covers, and give Dummy_grep the simplifications it
makes and a comment for each class variable.

Dummy_grep keeps engine and close, which grep_it calls.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@terryjreedy terryjreedy left a comment

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.

Approve with these changes. Another test is needed, but I want to move on to test_configdialog.

EDIT: I believe DummyRMenu.tk_popup, above 'click', should instead be a mock that can be asserted called.

Comment thread Lib/idlelib/idle_test/test_editor.py Outdated
Test the right click in a selection and not in one, as suggested.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread Lib/idlelib/idle_test/test_editor.py Outdated
Comment thread Lib/idlelib/idle_test/test_editor.py Outdated

@terryjreedy terryjreedy left a comment

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.

I checked test_configdialog well enough to merge. I added the ZZDummy 'extension' years ago partly so extension page tests could be written. Would have been tedious manually.

I am now convinced that Claude can help write decent idlelib tests.

@terryjreedy
terryjreedy merged commit f8f8c30 into python:main Sep 9, 2026
51 of 52 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka and @terryjreedy, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker f8f8c30ed4e20208e8badbc9e2fc3822e8db8e49 3.15

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka and @terryjreedy, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker f8f8c30ed4e20208e8badbc9e2fc3822e8db8e49 3.14

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka and @terryjreedy, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker f8f8c30ed4e20208e8badbc9e2fc3822e8db8e49 3.13

@terryjreedy

terryjreedy commented Sep 9, 2026

Copy link
Copy Markdown
Member

@serhiy-storchaka Can Claude fix the conflicts properly?

@serhiy-storchaka
serhiy-storchaka deleted the idle-test-placeholders branch September 9, 2026 08:27
@bedevere-app

bedevere-app Bot commented Sep 9, 2026

Copy link
Copy Markdown

GH-157204 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 9, 2026
@bedevere-app

bedevere-app Bot commented Sep 9, 2026

Copy link
Copy Markdown

GH-157205 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 9, 2026
@bedevere-app

bedevere-app Bot commented Sep 9, 2026

Copy link
Copy Markdown

GH-157206 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Sep 9, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Backported. Conflict was the same in all three -- Lib/.ruff.toml only exists on main.

@terryjreedy

Copy link
Copy Markdown
Member

Of course. I was puzzled because we had previously synchonized idlelib.

terryjreedy pushed a commit that referenced this pull request Sep 9, 2026
…) (#157205)

Restore the placeholder import in idlelib/idle_test/template.py
It was removed as an unused import in GH-151478, but template.py is a
skeleton for creating new IDLE test files, and idle_test/README.txt
instructs the user to replace 'zzdummy' with the name of the module
under test.  Add a Ruff per-file ignore to keep it.

test_editor.RMenuTest was added in GH-18951, which fixed right-clicking
inside a selection, with the note that an automated test should follow.
Use the DummyRMenu class left there to test right_menu_event(), and test
the rmenu_check_*() methods that supply the menu entry states.

test_configdialog.ConfigDialogTest was left with two empty stubs in
GH-3592, named after the two ConfigDialog methods which the button tests
only check to be called.  Test them with a fake parent whose instance
dictionary contains an autospecced EditorWindow.

 test_configdialog.ExtPageTest was added empty, with a commented-out
"Nothing here yet TODO" skip, when ExtPage was factored out of
ConfigDialog in GH-26618.  Test load_extensions(), extension_selected(),
set_extension_value() and save_all_changed_extensions().

test_grep.Default_commandTest was left empty in 2013 because
GrepDialog.default_command() imports OutputWindow when called, and the
import cannot be moved to the top of the module due to an import loop.
Replace the imported class with a mock instead of moving the import.

test_config.ChangesTest.test_save_default never called save_all(), so
it tested nothing.  Add the missing assertions, and add the test for
the Save() calls that the following TODO comment asked for.

test_config.IdleConfTest.test_get_current_keyset only tested the
non-darwin branch, because the default key sets no longer contain Alt
keys.  Add an extension binding with an Alt key, so that its
replacement with Option can be tested.  Remove the stale commented-out
test in test_get_extension_keys, which used the ZoomHeight extension.

---------



(cherry picked from commit f8f8c30)
terryjreedy pushed a commit that referenced this pull request Sep 9, 2026
…) (#157206)

Restore the placeholder import in idlelib/idle_test/template.py
It was removed as an unused import in GH-151478, but template.py is a
skeleton for creating new IDLE test files, and idle_test/README.txt
instructs the user to replace 'zzdummy' with the name of the module
under test.  Add a Ruff per-file ignore to keep it.

test_editor.RMenuTest was added in GH-18951, which fixed right-clicking
inside a selection, with the note that an automated test should follow.
Use the DummyRMenu class left there to test right_menu_event(), and test
the rmenu_check_*() methods that supply the menu entry states.

test_configdialog.ConfigDialogTest was left with two empty stubs in
GH-3592, named after the two ConfigDialog methods which the button tests
only check to be called.  Test them with a fake parent whose instance
dictionary contains an autospecced EditorWindow.

 test_configdialog.ExtPageTest was added empty, with a commented-out
"Nothing here yet TODO" skip, when ExtPage was factored out of
ConfigDialog in GH-26618.  Test load_extensions(), extension_selected(),
set_extension_value() and save_all_changed_extensions().

test_grep.Default_commandTest was left empty in 2013 because
GrepDialog.default_command() imports OutputWindow when called, and the
import cannot be moved to the top of the module due to an import loop.
Replace the imported class with a mock instead of moving the import.

test_config.ChangesTest.test_save_default never called save_all(), so
it tested nothing.  Add the missing assertions, and add the test for
the Save() calls that the following TODO comment asked for.

test_config.IdleConfTest.test_get_current_keyset only tested the
non-darwin branch, because the default key sets no longer contain Alt
keys.  Add an extension binding with an Alt key, so that its
replacement with Option can be tested.  Remove the stale commented-out
test in test_get_extension_keys, which used the ZoomHeight extension.

---------
Co-authored-by: Claude Opus 5 (1M context) noreply@anthropic.com
Co-authored-by: Hugo van Kemenade 1324225+hugovk@users.noreply.github.com
Co-authored-by: TerryJReedy tjreedy@udel.edu
Co-authored-by: Serhiy Storchaka storchaka@gmail.com


(cherry picked from commit f8f8c30)
hugovk pushed a commit that referenced this pull request Sep 9, 2026
…) (#157204)

Restore the placeholder import in idlelib/idle_test/template.py
It was removed as an unused import in GH-151478, but template.py is a
skeleton for creating new IDLE test files, and idle_test/README.txt
instructs the user to replace 'zzdummy' with the name of the module
under test.  Add a Ruff per-file ignore to keep it.

test_editor.RMenuTest was added in GH-18951, which fixed right-clicking
inside a selection, with the note that an automated test should follow.
Use the DummyRMenu class left there to test right_menu_event(), and test
the rmenu_check_*() methods that supply the menu entry states.

test_configdialog.ConfigDialogTest was left with two empty stubs in
GH-3592, named after the two ConfigDialog methods which the button tests
only check to be called.  Test them with a fake parent whose instance
dictionary contains an autospecced EditorWindow.

 test_configdialog.ExtPageTest was added empty, with a commented-out
"Nothing here yet TODO" skip, when ExtPage was factored out of
ConfigDialog in GH-26618.  Test load_extensions(), extension_selected(),
set_extension_value() and save_all_changed_extensions().

test_grep.Default_commandTest was left empty in 2013 because
GrepDialog.default_command() imports OutputWindow when called, and the
import cannot be moved to the top of the module due to an import loop.
Replace the imported class with a mock instead of moving the import.

test_config.ChangesTest.test_save_default never called save_all(), so
it tested nothing.  Add the missing assertions, and add the test for
the Save() calls that the following TODO comment asked for.

test_config.IdleConfTest.test_get_current_keyset only tested the
non-darwin branch, because the default key sets no longer contain Alt
keys.  Add an extension binding with an Alt key, so that its
replacement with Option can be tested.  Remove the stale commented-out
test in test_get_extension_keys, which used the ZoomHeight extension.

---------



(cherry picked from commit f8f8c30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants