[英]nosetests is capturing the output of my print statements. How to circumvent this?
當我打字
$ 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
)
用
--nologcapture
它對我有用
這是最近添加到鼻子而不是--nocapture
這樣做:
nosetests -s
為了與http://travis-ci.org集成,我已將其放入.travis.yml :
script: "python setup.py nosetests -s"
其中setup.py包含:
setup(
...
tests_require=['nose>=1.0'],
test_suite='nose.collector',
)
嘗試這個,
nosetests -v 2 -s yourtest
標志期待秩序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.