Re: [Tutor] unittest + tkinter

2010-11-02 Thread Alan Gauld


"Wayne Werner"  wrote

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.


Thats a feature of event driven programs. All the action takes place
inside the event loop. I don't know how you drive a GUI with unittest
though so can't help solve your problem. But the behaviour is normal
for any GUI.

Alan G.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] unittest + tkinter

2010-11-01 Thread Wayne Werner
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
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor