[Python-checkins] cpython (3.5): Issue #27918# test.resource.is_gui_available no longer flashes tk window.

terry.reedy python-checkins at python.org
Mon Sep 5 00:02:05 EDT 2016


https://hg.python.org/cpython/rev/756c27efe193
changeset:   103036:756c27efe193
branch:      3.5
parent:      103031:7108f2a708c9
user:        Terry Jan Reedy <tjreedy at udel.edu>
date:        Mon Sep 05 00:01:34 2016 -0400
summary:
  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.

files:
  Lib/test/support/__init__.py |  5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -464,6 +464,7 @@
         try:
             from tkinter import Tk
             root = Tk()
+            root.withdraw()
             root.update()
             root.destroy()
         except Exception as e:
@@ -488,12 +489,12 @@
 
 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 %r resource not enabled" % resource
         raise ResourceDenied(msg)
+    if resource == 'gui' and not _is_gui_available():
+        raise ResourceDenied(_is_gui_available.reason)
 
 def _requires_unix_version(sysname, min_version):
     """Decorator raising SkipTest if the OS is `sysname` and the version is less

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list