classification
Title: Make IDLE tests less flashy
Type: enhancement Stage: resolved
Components: IDLE Versions: Python 3.7, Python 3.6
process
Status: open Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: python-dev, terry.reedy, xiang.zhang
Priority: normal Keywords: patch

Created on 2016-09-01 00:33 by terry.reedy, last changed 2017-06-13 19:41 by terry.reedy.

Files
File name Uploaded Description Edit
flashy.diff terry.reedy, 2016-09-01 00:33 review
Pull Requests
URL Status Linked Edit
PR 2171 merged terry.reedy, 2017-06-13 18:06
PR 2172 merged terry.reedy, 2017-06-13 18:44
Messages (13)
msg274080 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-09-01 00:33
This issue follows-up on #27732, which suppressed beeps during IDLE tests, I want to also suppress the flashing of tk widget boxes, which has become visually obnoxious with the increasing number of tests.

Adding root.withdraw() after root = Tk() solves the problem for all current tests.  For test_textview, this requires the fix of a bad cleanup call and addition of another.  It appears that the textview toplevels must be destroyed before the cleanup call to root.update_idletasks() or else they are made visible.  The idletasks call is needed to avoid '''can't invoke "event" command''' (even with all toplevels gone).

The backports will have fewer changes because there are fewer tests.
msg274081 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-09-01 00:41
This is also a follow-up to #27918.  Importing test.support causes a flash in the process of testing whether tkinter/tk work.  So I was never able to get IDLE tests to completely stop flashing. Adding 'root.withdraw' to test.support.__init__ solves the import flash, and with that fix, individual IDLE tests and test_idle no longer flash.
msg274083 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-01 01:09
New changeset bf0cb86c6219 by Terry Jan Reedy in branch '2.7':
Issue #27922: IDLE tests no longer flash tk widgets.
https://hg.python.org/cpython/rev/bf0cb86c6219

New changeset ff3a6303c5b1 by Terry Jan Reedy in branch '3.5':
Issue #27922: IDLE tests no longer flash tk widgets.
https://hg.python.org/cpython/rev/ff3a6303c5b1

New changeset fc711879c64a by Terry Jan Reedy in branch 'default':
Issue #27922: IDLE tests no longer flash tk widgets (Merge 3.5).
https://hg.python.org/cpython/rev/fc711879c64a
msg274378 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-04 19:02
New changeset 6e4475894a79 by Terry Jan Reedy in branch '2.7':
Issue #27922: IDLE test_idlehistory no longer flash tk widgets.
https://hg.python.org/cpython/rev/6e4475894a79
msg274389 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-05 04:48
Hi Terry, I think this issue may be not completed. While running idlelib test with -ugui, I can sometimes still get a window flash. I think it's due to test_searchbase. Running python -m idlelib.idle_test.test_searchbase can reproduce the flash and adding withdraw doesn't work for me.
msg274390 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-05 05:49
After some tries, I think it seems to be caused by the second open in test_open_and_close in SearchDialogBaseTest. The second open calls self.top.deiconify.
msg274415 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-09-05 18:07
Thanks for the good detective work.  The flash is always there, somewhere, though sometimes minimal.  SearchBase.open begins with

        if not self.top:
            self.create_widgets()
        else:
            self.top.deiconify()
            self.top.tkraise()

The first and second open()s call the first and second branch.  I am puzzled that the first does not flash, as top is created 'normal' rather than 'withdrawn'.  It also turn out that commenting out either of the two lines stops the flash.

The flash could be prevented by changing 'else' to 'else if not _utest' and adding '_utest' as a parameter and passing True, as I have elsewhere.  However, the purpose of the second open() is to take that branch for near 100% coverage, and I have previously only used _utest to avoid blocking .wait_window calls.

I think I am going to leave this alone for now, but please feel free to comment on other IDLE issues.
msg274495 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-06 02:12
It's fine, knowing that the maintainer thinks this behaviour is okay. :)
msg276737 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-09-16 19:01
It is more a matter of tradeoffs rather than 'okay'.

There is no general pydev rule against gui flashing.  The tk and ttk gui tests still do, but that is primarily Serhiy's concern.

The IDLE tests are at most perhaps a third complete, so they would have become collectively 3 or more times worse.  I should run the IDLE tests at least once for each patch and usually do it multiple times.  When I work on a module or its tests, I tend work incrementally and run the test for the module 10 or 20 times or more.  So my first concern is my own eyes and mental state.

Second, I plan to ask others to run test_idle to make up for the lack of buildbot coverage, and I will feel better about doing so after the patches already made.  If one or a few flashes are left, I and others are still much better off.

In this case, there are two obvious fixes, but I don't like either.  Maybe I will come up with a third I like better, perhaps after some refactoring of the module.  I would also like to better understand the detailed behavior.  In the meanwhile, I reopened to add a comment to the test, so I don't lose track of the source of the remaining flash.
msg295946 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-13 18:01
Using findleak.py, attached to #30642, modified to always print the filename, I discovered that test_parenmatch also flashes (along with test_searchbase).  The leak test runs each test_xyz module 9 times, so is a good way to see flashing.

Adding 'root.withdraw' stops the single flash when running test_parenmatch once.  However, it does not stop flashing when running 9 times with -R: refleak test.  Flash continues even if class is reduced to

class ParenMatchTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.root = Tk()
        cls.root.withdraw()

    @classmethod
    def tearDownClass(cls):
        cls.root.destroy()
        del cls.root

    def test_dummy(self): pass

This is a puzzle since the same skeleton is in several other files.  In fact, at least one, test_autocomplete, does not even have root.withdraw. In any case, I will add it here.
msg295948 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-13 18:40
New changeset 049cf2bb44038351e1b2eed4fc7b1b522329e550 by terryjreedy in branch 'master':
bpo-27922: Stop gui flash from idle_test.test_parenmatch (#2171)
https://github.com/python/cpython/commit/049cf2bb44038351e1b2eed4fc7b1b522329e550
msg295955 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-13 19:41
New changeset d92ee3ea622b6eee5846681bad5595cfedcf20b6 by terryjreedy in branch '3.6':
[3.6]bpo-27922: Stop gui flash from idle_test.test_parenmatch (#2171) (#2172)
https://github.com/python/cpython/commit/d92ee3ea622b6eee5846681bad5595cfedcf20b6
msg295956 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-06-13 19:41
Using findleak.py, attached to #30642, modified to always print the filename, I discovered that test_parenmatch also flashes (along with test_searchbase).  The leak test runs each test_xyz module 9 times, so is a good way to see flashing.

Adding 'root.withdraw' stops the single flash when running test_parenmatch once.  However, it does not stop flashing when running 9 times with -R: refleak test.  Flash continues even if class is reduced to

class ParenMatchTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.root = Tk()
        cls.root.withdraw()

    @classmethod
    def tearDownClass(cls):
        cls.root.destroy()
        del cls.root

    def test_dummy(self): pass

This is a puzzle since the same skeleton is in several other files.  In fact, at least one, test_autocomplete, does not even have root.withdraw. In any case, I will add it here.
History
Date User Action Args
2017-06-13 19:41:25terry.reedysetmessages: + msg295956
2017-06-13 19:41:01terry.reedysetmessages: + msg295955
2017-06-13 18:44:47terry.reedysetpull_requests: + pull_request2224
2017-06-13 18:40:12terry.reedysetmessages: + msg295948
2017-06-13 18:06:20terry.reedysetpull_requests: + pull_request2223
2017-06-13 18:01:18terry.reedysetmessages: + msg295946
versions: + Python 3.7, - Python 2.7, Python 3.5
2016-09-16 19:01:25terry.reedysetstatus: closed -> open

messages: + msg276737
2016-09-06 02:12:36xiang.zhangsetmessages: + msg274495
2016-09-05 18:07:03terry.reedysetmessages: + msg274415
2016-09-05 05:49:03xiang.zhangsetmessages: + msg274390
2016-09-05 04:48:13xiang.zhangsetnosy: + xiang.zhang
messages: + msg274389
2016-09-04 19:02:54python-devsetmessages: + msg274378
2016-09-01 01:28:07terry.reedysetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2016-09-01 01:09:21python-devsetnosy: + python-dev
messages: + msg274083
2016-09-01 00:41:55terry.reedysetmessages: + msg274081
2016-09-01 00:33:36terry.reedycreate