problems redirecting unittest output to sys.stdout

Achim Domma achim.domma at syynx.de
Sat Apr 27 05:13:33 EDT 2002


Hi,

I want to redirect the output of a unittest to a textfile (on Windows). The
default stream is sys.stderr which can not be redirected on windows. Until
now I started my tests like this :

if __name__ == '__main__':
    unittest.main()

To redirect the output I tried the following :

if __name__ == '__main__':
    import sys
    unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout))

This way the output is redirected to sys.stdout, but the command line
parameters are ignored. If I call my script with the '-v' parameter, I get
no verbose output. I have no idee where the parameters get lost !?

any idea ?

greetings
Achim





More information about the Python-list mailing list