[issue27611] test_tix cannot import _default_root after test_idle

Terry J. Reedy report at bugs.python.org
Tue Aug 16 00:11:24 EDT 2016


Terry J. Reedy added the comment:

Ned Deily noticed the same problem when running with test.regrtest #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
.............................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 221 tests in 3.959s

OK
F:\Python\dev>36\pcbuild\win32\python_d.exe -m test -ugui test_tix test_idle test_tix
Run tests sequentially
0:00:00 [1/3] test_tix
0:00:00 [2/3] test_idle
0:00:03 [3/3] test_tix
All 3 tests OK.
 if __name__ == '__main__':
     unittest.main(verbosity=2, exit=False)
+    tk._support_default_root = 1
+    tk._default_root = None

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 #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.

----------

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


More information about the Python-bugs-list mailing list