Question
Asked By – Frankie Ribery
When I type
$ nosetests -v mytest.py
all my print outputs are captured when all tests pass.
I want to see print outputs even everything passes.
So what I’m doing is to force an assertion error to see the output, like this.
class MyTest(TestCase):
def setUp(self):
self.debug = False
def test_0(self):
a = .... # construct an instance of something
# ... some tests statements
print a.dump()
if self.debug:
eq_(0,1)
It feels so hackish, there must be a better way. Enlighten me please.
Now we will see solution for issue: nosetests is capturing the output of my print statements. How to circumvent this?
Answer
Either:
$ nosetests --nocapture mytest.py
Or:
$ NOSE_NOCAPTURE=1 nosetests mytests.py
(it can also be specified in the nose.cfg
file, see nosetests --help
)
This question is answered By – codeape
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0