classification
Title: Running test suites without gui but still having windows flash
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: martin.panter, ned.deily, python-dev, serhiy.storchaka, terry.reedy, xiang.zhang, zach.ware
Priority: normal Keywords: patch

Created on 2016-08-31 17:36 by xiang.zhang, last changed 2016-09-05 04:15 by terry.reedy. This issue is now closed.

Files
File name Uploaded Description Edit
issue27918.patch xiang.zhang, 2016-09-01 07:04 review
Messages (13)
msg274045 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-08-31 17:36
When I run test suites I find something interesting. Even if I don't enable gui resource there are still windows flashing. The two tests are test_idle and test_tk. I think the root cause is that they both use test.support.import_module with no reason and then root.update(in _is_gui_available) is called and windows flash. Comment out root.update windows are gone. Is this a must or can we find some way to suppress this?
msg274051 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-08-31 18:02
For your reference, the root.update is introduced in issue22770.
msg274052 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2016-08-31 18:06
The order of the checks in support.requires{,_resource} should be reversed: check if the resource is enabled, then check for gui availability if the resource in question is 'gui'.
msg274053 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-08-31 18:09
I tried that, no help to this thread, but I think that is better.

root.update itself draws something on the screen.
msg274054 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-08-31 18:12
Ahh, sorry. I misunderstand your message. Just ignore my last one. Really sorry for making noise.

Your suggestion makes sense I think.
msg274070 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-08-31 20:46
To my surprise, "python -m test test_idle" gives a single flash in Windows.  #22770 modified /Lib/test/support/__init__.py and added the creation and packing of a Label.  Those two lines are gone in repository 3.6 but the flash is still there, I added root.withdraw() at line 469 and the flash is gone.

        try:
            from tkinter import Tk
            root = Tk()
            root.withdraw()
            root.update()
            root.destroy()

I added a Label packing back and the flash is still gone here.

> "use test.support.import_module with no reason " ???
I used import_module in test_idle because I was told to and had to to prevent inappropriate test failures.  Please explain what you mean.
msg274086 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-09-01 01:27
Some time ago I tried adding 'root.withdraw' to idle_test files that used tkinter to stop the widget flashing.  This never worked completely.  Now I know why -- it was the test.support import.  Knowing this now, I opened #27922 to add 'root.withdraw' where else needed.  With support.__init__ patched, idle tests in 3.6 are currently flash-free, with -ugui, and 2.7 and 3.5 should be also.  So unless there is objection by tomorrow, I will patch all three versions.  I want the import flash suppressed even when -ugui is passed.
msg274087 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-01 02:34
> they both use test.support.import_module with no reason

Sorry, this is a typo. I meant to say "they both use test.support.requires". There should be *no* "no reason" and it's "requires" not "import_module". Sorry to confuse you. Staying late in night fools my brain.

I think it's nice to suppress the flash totally in support. Even gui is enabled a single support.requires may seem somewhat confusing to flash a window. Can we also apply Zachary's suggestion? If gui is not enable, there is no need to check _is_gui_available.
msg274092 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-09-01 03:48
I completely agree that we should not check that gui works unless and until it is requested.  Can you write a patch to do the switch?  

My point was that even when I request gui, I still don't want to see the flash.  I do TDD for test files as well as app files and I may run tests 10s of times in a day.  I will be happy to have that be a bit less stressful.
msg274094 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-01 04:41
It's my pleasure.

> My point was that even when I request gui, I still don't want to see the flash.

I also mean that in my last message, in this sentence " Even gui is enabled a single support.requires may seem somewhat confusing to flash a window". But it seems my poor English doesn't make it clear. :(

issue27918.patch does the switch and I add the withdrawn you suggest.
msg274333 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-09-04 03:46
Xiang’s second patch looks okay to me. The flashes occasionally annoy me with X windows if I am doing something else and have the Python tests running in the background.

I understand deferring the _is_gui_available() call will fix the main problem, and the withdraw() call is just an added nicety to avoid unnecessary windows when you actually enable -ugui.
msg274386 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-05 04:02
New changeset de9e410e78d8 by Terry Jan Reedy in branch '2.7':
Issue #27918# test.resource.is_gui_available no longer flashes tk window.
https://hg.python.org/cpython/rev/de9e410e78d8

New changeset 756c27efe193 by Terry Jan Reedy in branch '3.5':
Issue #27918# test.resource.is_gui_available no longer flashes tk window.
https://hg.python.org/cpython/rev/756c27efe193
msg274387 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-09-05 04:15
This issue only addresses and fixes the 1 flash per process from test.support.is_gui_available.  I separately added root.withdraw to IDLE tests in #27922, to stop their flashes.  Doing the same for tkinter tests would be a third issue.  I believe it would be easy since tkinter has a support module with mechanisms to set up and tear down root windows.  (I am thinking of something similar for IDLE.)  I leave this to Serhiy.
History
Date User Action Args
2016-09-05 04:15:59terry.reedysetstatus: open -> closed
messages: + msg274387

assignee: terry.reedy
resolution: fixed
stage: patch review -> resolved
2016-09-05 04:02:08python-devsetnosy: + python-dev
messages: + msg274386
2016-09-04 03:46:39martin.pantersetnosy: + martin.panter

messages: + msg274333
stage: patch review
2016-09-01 07:04:41xiang.zhangsetfiles: + issue27918.patch
2016-09-01 07:04:32xiang.zhangsetfiles: - issue27918.patch
2016-09-01 04:41:54xiang.zhangsetfiles: + issue27918.patch
keywords: + patch
messages: + msg274094
2016-09-01 03:48:24terry.reedysetmessages: + msg274092
2016-09-01 02:34:12xiang.zhangsetmessages: + msg274087
2016-09-01 01:27:45terry.reedysetmessages: + msg274086
2016-08-31 20:46:30terry.reedysetmessages: + msg274070
2016-08-31 18:12:16xiang.zhangsetmessages: + msg274054
2016-08-31 18:09:09xiang.zhangsetmessages: + msg274053
2016-08-31 18:06:31zach.waresetnosy: + zach.ware
messages: + msg274052
2016-08-31 18:02:46xiang.zhangsetmessages: + msg274051
2016-08-31 17:58:33ned.deilysetnosy: + terry.reedy, serhiy.storchaka
2016-08-31 17:36:42xiang.zhangcreate