-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
IDLE: Test UndoDelegator #65902
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
Adds test for UndoDelegator class in idlelib.UndoDelegator. With the help of Victor Stinner on IRC, I managed to reduce the refleak, but the current status is: Any hint on where the problem is? |
You should call "cls.percolator.close()" in your tearDownClass() method, before cls.text.destroy(). By the way, I prefer to assign an attribute to None instead of using "del obj.attr". |
cls.percolator.close() cut leaks in half. test_idle leaked [237, 237, 237, 237] references, sum=948 test_idle leaked [130, 130, 130, 130] references, sum=520 I prefixed name with 'x' and all leaks disappeared. When I run the test, a tk box is left. My guess is that something is being created with tkinter._default_root as master. I do not think it is in UndoDelegator, so I would look at Percolator, WidgetDirector, Delegator, and the new test file. --- --- def _undo_delegator(parent): # htest #
import re
import tkinter as tk
from idlelib.Percolator import Percolator
root = tk.Tk()
root.title("Test UndoDelegator")
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
root.geometry("+%d+%d"%(x, y + 150))
text = tk.Text(root)
text.config(height=10)
text.pack()
text.focus_set()
p = Percolator(text)
d = UndoDelegator()
p.insertfilter(d)
undo = tk.Button(root, text="Undo", command=lambda:d.undo_event(None))
undo.pack(side='left')
redo = tk.Button(root, text="Redo", command=lambda:d.redo_event(None))
redo.pack(side='left')
dump = tk.Button(root, text="Dump", command=lambda:d.dump_event(None))
dump.pack(side='left')
root.mainloop()
if __name__ == "__main__":
import unittest
unittest.main('idlelib.idle_test.test_undodelegator', verbosity=2,
exit=False)
from idlelib.idle_test.htest import run
run(_undo_delegator) |
It was WidgetRedirector which was leaking. saimadhav@debian:~/dev/34-cpython$ ./python -m test -R :: -uall test_idle The attached patch also ensures that when UndoDelegator.py is run, unittest is called with exit=False, so that htest is run. Only problem remaining is when UndoDelegator is run, can't invoke "event" command: application has been destroyed |
Great. I will review the next patch (with the change in the comment) tomorrow. The ttk theme changed message comes up often. I believe it is specific to debug builds. Perhaps you could keep track of when it occurs so we can make a guess at the cause. I believe I asked Serhiy once and he did not then know why. I believe I grepped at least one of tkinter and _tkinter for ttk and did not fine anything. It does not cause buildbot failures, but may be involved with one of the warnings. It does suggest at least a minor bug, though, and it would be nice to fix. The environment change warning, at least on windows, is probably from module tkinter._fix imported in tkinter. |
Before looking at this, I ran the leak tests and found a worse problem in the test suite. I opened bpo-27044 and fixed the problem. I did not get the 'theme changed' message (msg220243) when running the leak test in the console, but did when running it either the file or test_file as __main__. In the former case, the process is started by test.regrtest, which ends up calling unittest. This is how buildbots run. In the latter case, the process is started by the idlelib file, which calls unittest. |
New changeset ce1b14ed5445 by Terry Jan Reedy in branch '3.5': |
Solved 'theme' problem by adding to end of tearDownClass |
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: