mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
871a3340b7
commit
fb5ce7eea1
|
@ -464,6 +464,7 @@ def _is_gui_available():
|
||||||
try:
|
try:
|
||||||
from tkinter import Tk
|
from tkinter import Tk
|
||||||
root = Tk()
|
root = Tk()
|
||||||
|
root.withdraw()
|
||||||
root.update()
|
root.update()
|
||||||
root.destroy()
|
root.destroy()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -488,12 +489,12 @@ def is_resource_enabled(resource):
|
||||||
|
|
||||||
def requires(resource, msg=None):
|
def requires(resource, msg=None):
|
||||||
"""Raise ResourceDenied if the specified resource is not available."""
|
"""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 not is_resource_enabled(resource):
|
||||||
if msg is None:
|
if msg is None:
|
||||||
msg = "Use of the %r resource not enabled" % resource
|
msg = "Use of the %r resource not enabled" % resource
|
||||||
raise ResourceDenied(msg)
|
raise ResourceDenied(msg)
|
||||||
|
if resource == 'gui' and not _is_gui_available():
|
||||||
|
raise ResourceDenied(_is_gui_available.reason)
|
||||||
|
|
||||||
def _requires_unix_version(sysname, min_version):
|
def _requires_unix_version(sysname, min_version):
|
||||||
"""Decorator raising SkipTest if the OS is `sysname` and the version is less
|
"""Decorator raising SkipTest if the OS is `sysname` and the version is less
|
||||||
|
|
Loading…
Reference in New Issue