Fra*_*ery 142 python nosetests
当我输入
$ nosetests -v mytest.py
Run Code Online (Sandbox Code Playgroud)
所有测试通过后,我的所有打印输出都被捕获.我想看看打印输出甚至一切都过去了.
所以我正在做的是强制断言错误来查看输出,就像这样.
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)
Run Code Online (Sandbox Code Playgroud)
感觉如此hackish,必须有一个更好的方式.请赐教.
cod*_*ape 216
或者:
$ nosetests --nocapture mytest.py
Run Code Online (Sandbox Code Playgroud)
要么:
$ NOSE_NOCAPTURE=1 nosetests mytests.py
Run Code Online (Sandbox Code Playgroud)
(也可以在nose.cfg文件中指定,参见nosetests --help)
最近添加到鼻子而不是--nocapture这样做:
nosetests -s