[issue18441] Idle: Make test.support.requires('gui') skip when it should.

Terry J. Reedy report at bugs.python.org
Sun Jul 14 00:34:07 CEST 2013


New submission from Terry J. Reedy:

This is a continuation of #18365, where it was discovered after the first set of pushes that
    test.support.requires('gui')
is currently insufficient (on non-Windows systems) for skipping gui tests on buildbots when they should be skipped, because the attempt to create a Tk root widget will raise TclError when there is no display available.

This bug appears to arise from the confluence of two bugs:

1. It appears that on some buildbots, support.use_resources contains 'gui' when it should not. The could be either from -ugui or -uall without  '.-gui' or ???.

2. test.support.requires starts with
     if resource == 'gui' and not _is_gui_available():
On windows, _is_gui_available() uses ctypes to determine that there really is a graphics screen (or something like that). On other systems, it just returns True, even when it should return False.

The problem was fixed for #18365 by wrapping the tkinter.Tk call with try:...except: TclErrror: raise SkipTest. Rather than put something like that workaround in every idle_test/test_xxx file, I would like to do the test once in test/test_idle and if it does not work, remove 'gui' from use_resources so requires('gui') will work properly. See patch.

test/test_ttkguionly does not use requires() (and therefore does not do the special Windows check). It first tries to import _tkinter, as does test_idle. It then calls tkinter.test.support.check_tk_availability. That either does a 'darwin'-ctypes check similar to the one for Windows in _is_gui_available or it tries to create a tk widget and looks for a TclError. test_ttkguionly then repeats the widget creation test.

This checking is ok for one file, but not for gui tests sprinkled throughout idle's test_xxx files. Perhaps requires('gui') not being dependable is why there is a separate test_ttkguionly file *and* a custom discovery function, tkinter.test.runtests.get_tests, to get only gui tests.

test/test_tk does the same except that is does not repeat the widget creation test. Both add 'gui' to use_resources when the file is run as main, though in a more convoluted manner than in test_idle. I am sure that removing 'gui' in test_idle cannot hurt since test_tk/ttk_gui-only skip anyway on a similar TclError. There is no test_turtle.py.

The check should really be done in regrtest, but I am not familiar with its code or the policy on patching it. Then tkinter tests could also dispense with their extra checks and more easily be converted to use unittest discovery. But that is not my concern here.

----------
assignee: terry.reedy
files: delete_gui.diff
keywords: patch
messages: 193015
nosy: r.david.murray, terry.reedy
priority: high
severity: normal
stage: commit review
status: open
title: Idle: Make test.support.requires('gui') skip when it should.
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file30909/delete_gui.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18441>
_______________________________________


More information about the Python-bugs-list mailing list