鼻子测试正在捕获我的打印语句的输出.如何规避呢? [英] nosetests is capturing the output of my print statements. How to circumvent this?

查看:78
本文介绍了鼻子测试正在捕获我的打印语句的输出.如何规避呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我键入

$ 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.

推荐答案

任一:

$ nosetests --nocapture mytest.py

或者:

$ NOSE_NOCAPTURE=1 nosetests mytests.py

(也可以在nose.cfg文件中指定,请参见nosetests --help)

(it can also be specified in the nose.cfg file, see nosetests --help)

这篇关于鼻子测试正在捕获我的打印语句的输出.如何规避呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆