Author terry.reedy
Recipients r.david.murray, terry.reedy
Date 2013-07-13.22:34:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This is a continuation of #18365, where it was discovered after the first set of pushes that'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. 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 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

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.
Date User Action Args
2013-07-13 22:34:07terry.reedysetrecipients: + terry.reedy, r.david.murray
2013-07-13 22:34:07terry.reedysetmessageid: <>
2013-07-13 22:34:07terry.reedylinkissue18441 messages
2013-07-13 22:34:06terry.reedycreate