Commit ef2020f6 authored by Terry Jan Reedy's avatar Terry Jan Reedy

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.
parent cb251981
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment