Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running test suites without gui but still having windows flash #72105

Closed
zhangyangyu opened this issue Aug 31, 2016 · 13 comments
Closed

Running test suites without gui but still having windows flash #72105

zhangyangyu opened this issue Aug 31, 2016 · 13 comments
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@zhangyangyu
Copy link
Member

BPO 27918
Nosy @terryjreedy, @ned-deily, @vadmium, @zware, @serhiy-storchaka, @zhangyangyu
Files
  • issue27918.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2016-09-05.04:15:59.898>
    created_at = <Date 2016-08-31.17:36:42.320>
    labels = ['type-bug', 'tests']
    title = 'Running test suites without gui but still having windows flash'
    updated_at = <Date 2016-09-05.04:15:59.897>
    user = 'https://github.com/zhangyangyu'

    bugs.python.org fields:

    activity = <Date 2016-09-05.04:15:59.897>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2016-09-05.04:15:59.898>
    closer = 'terry.reedy'
    components = ['Tests']
    creation = <Date 2016-08-31.17:36:42.320>
    creator = 'xiang.zhang'
    dependencies = []
    files = ['44315']
    hgrepos = []
    issue_num = 27918
    keywords = ['patch']
    message_count = 13.0
    messages = ['274045', '274051', '274052', '274053', '274054', '274070', '274086', '274087', '274092', '274094', '274333', '274386', '274387']
    nosy_count = 7.0
    nosy_names = ['terry.reedy', 'ned.deily', 'python-dev', 'martin.panter', 'zach.ware', 'serhiy.storchaka', 'xiang.zhang']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27918'
    versions = ['Python 3.6']

    @zhangyangyu
    Copy link
    Member Author

    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?

    @zhangyangyu zhangyangyu added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Aug 31, 2016
    @zhangyangyu
    Copy link
    Member Author

    For your reference, the root.update is introduced in bpo-22770.

    @zware
    Copy link
    Member

    zware commented Aug 31, 2016

    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'.

    @zhangyangyu
    Copy link
    Member Author

    I tried that, no help to this thread, but I think that is better.

    root.update itself draws something on the screen.

    @zhangyangyu
    Copy link
    Member Author

    Ahh, sorry. I misunderstand your message. Just ignore my last one. Really sorry for making noise.

    Your suggestion makes sense I think.

    @terryjreedy
    Copy link
    Member

    To my surprise, "python -m test test_idle" gives a single flash in Windows. bpo-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.

    @terryjreedy
    Copy link
    Member

    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 bpo-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.

    @zhangyangyu
    Copy link
    Member Author

    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.

    @terryjreedy
    Copy link
    Member

    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.

    @zhangyangyu
    Copy link
    Member Author

    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. :(

    bpo-27918.patch does the switch and I add the withdrawn you suggest.

    @vadmium
    Copy link
    Member

    vadmium commented Sep 4, 2016

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 5, 2016

    New changeset de9e410e78d8 by Terry Jan Reedy in branch '2.7':
    Issue bpo-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 bpo-27918# test.resource.is_gui_available no longer flashes tk window.
    https://hg.python.org/cpython/rev/756c27efe193

    @terryjreedy
    Copy link
    Member

    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 bpo-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.

    @terryjreedy terryjreedy self-assigned this Sep 5, 2016
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants