Author terry.reedy
Recipients Saimadhav.Heblikar, jesstess, terry.reedy, vstinner
Date 2014-06-11.06:43:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1402469001.33.0.512476716734.issue21703@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2014-06-11 06:43:21terry.reedysetrecipients: + terry.reedy, vstinner, jesstess, Saimadhav.Heblikar
2014-06-11 06:43:21terry.reedysetmessageid: <1402469001.33.0.512476716734.issue21703@psf.upfronthosting.co.za>
2014-06-11 06:43:21terry.reedylinkissue21703 messages
2014-06-11 06:43:20terry.reedycreate