Redirecting unittest output to a Text widget

MrBlueSky penneys at bigfoot.com
Wed May 10 09:01:16 CEST 2006


Morning!  I'm writing my first Python program, so please have patience!

I'd like to redirect the output from my application's unit tests
("import unittest") to a Tkinter Text object.  I found the magic to
redirect stdout and stderr:
    sys.stdout = myTextWindow
    sys.stderr = myTextWindow
where myTextWindow inherits from Text and implements write() and
writelines().

But the output from my UT still appears in the command window, not the
Text box.  My own "print" statements *do* appear in the Text box.

Can anyone suggest a way forward here?

John




More information about the Python-list mailing list