Re: [Pyunit-interest] stderr vs. stdout
Brought to you by:
purcell
From: Steve P. <ste...@ya...> - 2001-02-18 08:54:21
|
Chuck Esterbrook wrote: > But all the output goes to the console anyway and results.text is 0 bytes > in length. A little investigation reveals that VerboseTextTestRunner > defaults to sys.stderr: > > def __init__(self, stream=sys.stderr, descriptions=1): > > Is there a reason to default to stderr instead of stdout? Hi Chuck, I don't know if it was the wisest decision in the world, but I think I figured at the time that stderr was the standard stream least likely to conflict with any output that the tested code might sporadically print. That is, if the code being tested is sprinkled with 'print' statements (god forbid), printing the test results to stderr instead means that you can get the test results text on a distinct stream. You should still be able to get the test results into a file by doing: ./mytests.py 2>results.log (at least on UNIX). You might also consider: if __name__ == '__main__': runner = unittest.TextTestRunner(sys.stdout) unittest.main(defaultTest='suite', testRunner=runner) Hope that helps. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Get servlets at http://pyserv.sourceforge.net/ "Even snakes are afraid of snakes." -- Steven Wright |