Edit: Please notice I'm using Python 2.6 (as tagged)
Say I have the following:
class Foo:
def bar(self):
print 'bar'
return 7
And say I have the following unit test:
import unittest
class ut_Foo(unittest.TestCase):
def test_bar(self):
obj = Foo()
res = obj.bar()
self.assertEqual(res, 7)
So if I run:
unittest.main()
I get:
bar # <-- I don't want this, but I *do* want the rest
.
----------------------------------------------------------------------
Ran 1 test in 0.002s
OK
Exit code: False
My question is: Is there a way to suppress the output of the object being tested while still getting the output of the unittest framework?
Edit This question is not a duplicate of the flagged question which is asking about silencing stdout of a particular function within a normal python script.
Whereas this question is asking about hiding the normal stdout of a python script while running it's unittests. I still want the unittest stdout to be displayed, and I don't want to disable the stdout of my tested script.