[Tutor] unittest + tkinter

Wayne Werner waynejwerner at gmail.com
Tue Nov 2 03:10:39 CET 2010


I'm sure there's an incredibly simple way to do this, but at the moment it
eludes me.

I'm trying my hand at test driven development via the unittest module. Since
my program is using Tkinter, my thought is that I need to create the main
window. The only problem is that when I launch the main loop, further lines
of code aren't executed.

#simple.py
import Tkinter as tk

class Simple(tk.Tk):
     def __init__(self):
        tk.Tk.__init__(self)
        self.mainloop()

# test.py
import unittest
import simple

class SimpleTestCase(unittest.TestCase):
    def testSimple(self):
        s = simple.Simple()
        print 'hi' # have to close the window before this happens

unittest.main()

Am I on the right track? or am I way out in left field? Any pointers/help in
the right direction?

Thanks,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101101/1a1b82da/attachment.html>


More information about the Tutor mailing list