-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
test_tix cannot import _default_root after test_idle #71798
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
Comments
$ ./python -m unittest -v test.test_{idle,tix}
. . .
test_tix (unittest.loader._FailedTest) ... ERROR ====================================================================== ImportError: Failed to import test module: test_tix
Traceback (most recent call last):
File "/media/disk/home/proj/python/cpython/Lib/unittest/loader.py", line 153, in loadTestsFromName
module = __import__(module_name)
File "/media/disk/home/proj/python/cpython/Lib/test/test_tix.py", line 11, in <module>
from tkinter import tix, TclError
File "/media/disk/home/proj/python/cpython/Lib/tkinter/tix.py", line 30, in <module>
from tkinter import _cnfmerge, _default_root
ImportError: cannot import name '_default_root' Without test_idle, test_tix is skipped for me: $ ./python -m unittest -v test.test_tix
test_tix_available (test.test_tix.TestTix) ... skipped 'Tix not available' Reverting to before revision 064b29dde096 (bpo-24137) also fixes the failure. |
There is a bug in tix. _default_root shouldn't be imported, since this is modifiable attribute. |
I could reverse the effect of test_idle calling tk.NoDefaultRoot by adding |
I think there are two bugs to be fixed here:
|
New changeset 5c76f787e695 by Terry Jan Reedy in branch 'default': |
bpo-24137 only patched default, so either too many versions were selected or there is another bug in test_tix. Martin and Serhiy can sort that out. The restore patch I pushed is based on this from tkinter.__init__ _support_default_root = 1
_default_root = None
def NoDefaultRoot():
"""Inhibit setting of default root window.
|
New changeset a6a248479b66 by Terry Jan Reedy in branch 'default': |
Ned Deily noticed the same problem when running with test.regrtest bpo-27714. I cannot reproduce this issue when running both tests either with unittest or test.regrtest. F:\Python\dev>36\pcbuild\win32\python_d.exe -m unittest test.test_tix test.test_idle test.test_tix OK Zach, I don't know of any way to get either unittest or test.regrtest to run anything in test_idle after it runs the test collector *and* the tests. Do you? The addition of tk.NoDefaultRoot() to both IDLE and its tests was suggested by Serhiy in bpo-24137. Doing so exposed several issues in htests but no real bugs in IDLE itself. My patch to restore tkinter module only works when test_idle is run as main. So as far as that patch goes, tkinter should only changed when the test is run as main. I will move the call. I have already changed my check script to run test_idle this way. Otherwise, the easiest way to leave tkinter as it was when testing ends is to not change it. I am aware that tkinter tests avoid the by defining a mixin class with class methods that call and undo the call. It is used in 11 test classes within the tkinter and ttk tests. However, this refactoring would be harder to apply to IDLE tests and not sufficient in itself. It is at best a future project. I added a guard to IDLE's NoDefaultRoot call for when pyshell.main is broken into multiple testable functions. |
New changeset cddd633b959f by Terry Jan Reedy in branch '2.7': New changeset a42933335897 by Terry Jan Reedy in branch '3.5': |
Terry, you committed not full patch. The tix module still doesn't work after NoDefaultRoot(). |
What do you mean by 'does not work' and what did I omit? |
DisplayStyle() fails with AttributeError after NoDefaultRoot(). Should be made following changes:
|
This issue is about test_tix failing when run after test_idle, due to the conjunction of two specific causes, one old (tix importing _default_root), one new (IDLE deleting and not restoring _default_root). The new cause exposed the old. Fixing either cause would have negated the conjunction, but at Zack's urging, I fixed both. I even did one extra bit of cleanup in moving the tkinter and os imports to the top where they belong. In my view, my patch was more than complete and this issue is fixed and should have remained closed and should be reclosed. Serhiy, when I wrote the tix patch, I was aware that tix remains buggy in that it will fail if a *user* imports tix, removes _default_root, and calls either of the functions that unconditionally access the attribute. Since test_tix only tests that the tix can be imported and that tix.Tk runs, there may be more bugs. And more cleanups might be needed. However, patching tix to work better is a different issue than this one. If you want, open a new issue, add some tests, and write the patch you outlined. |
New changeset 94a26aa1b1e0 by Serhiy Storchaka in branch '2.7': New changeset 7b458bcdab75 by Serhiy Storchaka in branch '3.5': New changeset ec3f5d21bec0 by Serhiy Storchaka in branch '3.6': New changeset 1c5e0dbcb2a0 by Serhiy Storchaka in branch 'default': |
Misc/NEWS
so that it is managed by towncrier #552Note: 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: