New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idle: Make test.support.requires('gui') skip when it should. #62641
Comments
This is a continuation of bpo-18365, where it was discovered after the first set of pushes that This bug appears to arise from the confluence of two bugs:
The problem was fixed for bpo-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. |
See bpo-8716 for the history of check_tk_availability(). At the time, the Tk tests were the only ones trying to create real Tk objects (and thus causing crashes on some buildbot configurations). With the addition of IDLE tests that call Tk, it probably makes sense to refactor check_tk_availability() into the common test test_support/support helper module so it can be used globally. |
New changeset 23b0164b9c82 by Terry Jan Reedy in branch '2.7': |
I took a look. Not fun ;-). Pending a more permanent fix, I am applying a revised patch, first to 2.7 to make sure it works. |
New changeset 9f922270a929 by Terry Jan Reedy in branch '2.7': |
New changeset e8b8279ca118 by Terry Jan Reedy in branch '2.7': |
(The fix was incomplete because 'delete' in the except clause should be 'remove'.) I finally realized that I could test the except clause by raising TclError explicitly just before it. I reverted both changes because they do not seem to work, even with the additional fix (not committed). With or without patches, It seems that 'gui' is not being removed from use_resources. Since debug print()s in test_idle do not show up on the console, I cannot easily see what is going on. |
More noise. Much of what I said above was incorrect due to version mixup. The one extra fix I did not commit might have been enough, but I will wait until I have tested it. |
New changeset dd9941f5fcda by Terry Jan Reedy in branch '2.7': New changeset d9a53ab464ea by Terry Jan Reedy in branch '2.7': |
New changeset 9a4c62c1a4c0 by Terry Jan Reedy in branch '2.7': New changeset ba5c264d67ea by Terry Jan Reedy in branch '2.7': New changeset 6420dcd377f9 by Terry Jan Reedy in branch '2.7': |
I tried to run the currently unnecessary Mac 'darwin' check in 2.7 with This fails because 'lib-tk' is not a legal module name. There are workarounds in test/test_tk.py and test_ttk_guionly, but I decided not to bother with them now because I would rather work on moving the function to test.support (and perhaps the package could be given a legal name). If, before that is done, someone adds a Mac buildbot that will not run gui tests but requests that they be run anyway, the above could be added with the different changes needed for 2.7 and 3.x. |
New changeset c3936a52f215 by Terry Jan Reedy in branch '3.3': New changeset 858a72d91162 by Terry Jan Reedy in branch '2.7': |
New changeset c57b2a344097 by Terry Jan Reedy in branch '3.3': |
This is working, so closing. I opened bpo-18604 for consolidating gui checks in test.support. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: