diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2016-09-05 04:01:34 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2016-09-05 04:01:34 (GMT) |
commit | fb5ce7eea18b287679f4a8b70c2391f6e9d71833 (patch) | |
tree | 92dd57acd0918ae255a8a0974ed663aeb5b9c068 | |
parent | 871a3340b7d72a5ef783ace7baa5cd8428d226d2 (diff) | |
download | cpython-fb5ce7eea18b287679f4a8b70c2391f6e9d71833.zip cpython-fb5ce7eea18b287679f4a8b70c2391f6e9d71833.tar.gz cpython-fb5ce7eea18b287679f4a8b70c2391f6e9d71833.tar.bz2 |
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.
-rw-r--r-- | 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 index 867dc2f..007f3bc 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -464,6 +464,7 @@ def _is_gui_available(): try: from tkinter import Tk root = Tk() + root.withdraw() root.update() root.destroy() except Exception as e: @@ -488,12 +489,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 %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 |