[issue21703] IDLE: Test UndoDelegator

Terry J. Reedy report at bugs.python.org
Wed Jun 11 08:43:21 CEST 2014


Terry J. Reedy added the comment:

cls.percolator.close() cut leaks in half.

test_idle leaked [237, 237, 237, 237] references, sum=948
test_idle leaked [95, 97, 97, 97] memory blocks, sum=386

test_idle leaked [130, 130, 130, 130] references, sum=520
test_idle leaked [60, 62, 62, 62] memory blocks, sum=246

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. 

---
See review comment for increasing coverage to about 80%, which is very good.

---
When unittest call precedes htest.run call, need exit=False or htest is skipped by unittest exiting process. Part of testing is running tests from module. Even with the addition, htest is not running right (buttons in main windows are not right). The might be an effect of the unittest not being properly terminated. It is still true after I added the missing re import. Htest runs fine by itself. See #21624 for changes.  Revised code:

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)

----------

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


More information about the Python-bugs-list mailing list