In unittest docs [ http://docs.python.org/2/library/unittest.html#unittest.main ] I see the following method signature:
unittest.main([module[, defaultTest[, argv[, testRunner[, testLoader[, exit[, verbosity[, failfast[, catchbreak[, buffer]]]]]]]]]])
The last parameter is the "buffer". The docs explain the following about this option:
The failfast, catchbreak, and buffer options have the same effect as the command line options with the same name.
The docs for the command line options [ http://docs.python.org/2/library/unittest.html#command-line-options ] explain the buffer as follows:
-b, --buffer
Standard output and standard error streams are buffered during the test run. The output during the test is discarded. The output is usually repeated when a test error or error is added to the error messages.
I have the following demo code that does not demonstrate the behavior that might be expected:
import unittest2 class DemoTest(unittest2.TestCase): def test_one(self): self.assertTrue(True) def test_two(self): self.assertTrue(True) if __name__ == '__main__': test_program = unittest2.main(verbosity=0, buffer=True, exit=False)
The output of this program:
---------------------------------------------------------------------- Ran 2 tests in 0.000s OK
In fact, I get the same result if I change the last line in my program to:
test_program = unittest2.main(verbosity=0, buffer="hello", exit=False)
What am I doing wrong? (I tried using unittest instead of unittest2 , but that didn't matter.)