This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE tests should be quiet
Type: enhancement Stage: resolved
Components: IDLE Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: python-dev, terry.reedy, zach.ware
Priority: normal Keywords:

Created on 2016-08-11 01:02 by terry.reedy, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg272390 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-08-11 01:02
IDLE uses tkinter.widget.bell() in various places to signal an exceptional situation.  Examples include 'Find' when the target cannot be found and 'Expand word' when there is no expansion (or are no more expansions.

[The tk manual page is http://www.tcl.tk/man/tcl8.6/TkCmd/bell.htm.  I have no idea what difference it makes which window the bell is rung on.

When running test_idle, there are about 5 beeps.  They serve no purpose and can only discourage buildbot owners from running gui tests, even if they could.  Test_tk and test_ttk_guionly are silent.

A solution is to replace something like 'self.text.bell' with 'self.bell', where the latter is either the former or 'lambda: None', depending on a 'utest=False' parameter.

The replacement could lead to the following bonus in a follow-on issue: a separate function could be augmented to emit a 'visual bell', a signal that is seen rather than heard.  This would benefit both the hard-of-hearing and those who edit with sound turned off or redirected to headphones not worn.  Notepad++ somehow flashes the Search dialog title bar as well a adding a message to the status bar.  I would rather flash (blink) the text not found or expanded.  The idea is to replace a hard-coded external function with a custom wrapper subject to future improvement.
msg272391 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2016-08-11 01:06
You could guard the noisy tests with "@support.requires_resource('audio')" (however that is actually spelled :)).
msg272396 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-08-11 03:45
New changeset 2eb84fe85889 by Terry Jan Reedy in branch 'default':
Issue #27732: Silence test_idle with dummy bell functions.
https://hg.python.org/cpython/rev/2eb84fe85889
msg272399 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-08-11 04:07
Bell-using files patched (module and test)
autoexpand, parenmatch, replace, search, undo

Bell-using files not patched (no test yet) 
debugger, editor, grep, history, pyshell, scrolled_list, zoomheight

A second bonus is that the dummy bell function, instead of lambda: None, can be a mock used to test that bell() was called when it should be (or even not).  This was already true for test_undo, except that the mock wrapped rather than replaced the real bell function.  I opened spinoff #27733 to extend this idea.

To make this possible, I gave the class instances a self.bell function that was replaced by the test code afterwards.  I am leaving this issue open to give the other bell-using classes a similar attribute in preparation for future tests.
msg272400 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-08-11 04:19
> @support.requires_resource('audio')?

The point is that the noise is extraneous and should be optional.  I want the tests to run (quietly) when I run them with unittest (which is most of the time) and anytime -ugui is true (too few of the buildbots).  It was not too hard fix and has bonuses both for normal running and for tests.  The parenmatch module has an option to turn off noise, and I might generalize that option, while still providing visual signals.
History
Date User Action Args
2022-04-11 14:58:34adminsetgithub: 71919
2020-06-06 19:34:00terry.reedysetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2016-08-11 04:19:55terry.reedysetmessages: + msg272400
2016-08-11 04:07:21terry.reedysetmessages: + msg272399
2016-08-11 03:45:12python-devsetnosy: + python-dev
messages: + msg272396
2016-08-11 01:06:30zach.waresetnosy: + zach.ware
messages: + msg272391
2016-08-11 01:02:30terry.reedycreate