当我输入时
$ nosetests -v mytest.py
当所有测试都通过时,我的所有打印输出都会被捕获。 即使一切都通过了,我也想看到打印输出。
所以我正在做的是强制一个断言错误来查看输出,就像这样。
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)
感觉太hackish了,一定有更好的方法。请赐教。
最佳答案
要么:
$ nosetests --nocapture mytest.py
或者:
$ NOSE_NOCAPTURE=1 nosetests mytests.py
(也可以在nose.cfg
文件中指定,见nosetests --help
)
关于python - nosetests 正在捕获我的打印语句的输出。如何规避这一点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5975194/