This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bialix
Recipients bialix
Date 2012-10-08.11:58:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1349697500.62.0.333745951917.issue16164@psf.upfronthosting.co.za>
In-reply-to
Content
Why by default unittest.main (which uses unittest.TextTestRunner) prints everything to stderr. What the reason behind this behavior?
It makes very inconvenient to run big test suite with less, i.e.

python test.py | less 

or

python test.py > test.log

does not show me failed tests. They all go to stderr. Why?

Another thing: there is no easy way to override this. I have to subclass either TestProgram or TextTestRunner and force sys.stdout rather than sys.stderr. E.g.

class TestProgram(unittest.TestProgram):

    def runTests(self):
        if self.testRunner is None:
            self.testRunner = unittest.TextTestRunner(stream=sys.stdout, verbosity=self.verbosity)
        result = self.testRunner.run(self.test)
        sys.exit(not result.wasSuccessful())

if __name__ == '__main__':
    TestProgram()

Although it works for me I feel there is something wrong. Am I the only person who needs test output on stdout?
History
Date User Action Args
2012-10-08 11:58:20bialixsetrecipients: + bialix
2012-10-08 11:58:20bialixsetmessageid: <1349697500.62.0.333745951917.issue16164@psf.upfronthosting.co.za>
2012-10-08 11:58:20bialixlinkissue16164 messages
2012-10-08 11:58:19bialixcreate