From: Terry Jan Reedy Date: Mon, 5 Sep 2016 04:01:28 +0000 (-0400) Subject: Issue #27918# test.resource.is_gui_available no longer flashes tk window. X-Git-Tag: v2.7.13rc1~184 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef2020f63421c896dc9ed58d09f5b402f36789e2;p=thirdparty%2FPython%2Fcpython.git Issue #27918# test.resource.is_gui_available no longer flashes tk window. Also, don't run it if 'gui' is not requested. Patch by Xiang Zhang. --- diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 89c5719df5d8..2fba2a36d7b0 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -331,6 +331,7 @@ def _is_gui_available(): try: from Tkinter import Tk root = Tk() + root.withdraw() root.update() root.destroy() except Exception as e: @@ -355,12 +356,12 @@ def is_resource_enabled(resource): def requires(resource, msg=None): """Raise ResourceDenied if the specified resource is not available.""" - if resource == 'gui' and not _is_gui_available(): - raise ResourceDenied(_is_gui_available.reason) if not is_resource_enabled(resource): if msg is None: msg = "Use of the `%s' resource not enabled" % resource raise ResourceDenied(msg) + if resource == 'gui' and not _is_gui_available(): + raise ResourceDenied(_is_gui_available.reason) def requires_mac_ver(*min_version): """Decorator raising SkipTest if the OS is Mac OS X and the OS X