python - nosetests 正在捕获我的打印语句的输出。如何规避这一点?

标签 python nosetests

当我输入时

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

相关文章:

python - 我可以将 Nose 覆盖输出限制到目录(而不是包)吗?

python - Dataframe:从单个 ID 中提取多个 parent 并计算出现次数

python - Keras 顺序模型与功能 API 的不一致

python - django admin 自定义命令 - 将字符串列表传递给 args

pydev Nose 测试测试运行

testing - 如何测试程序是否退出

python - 谷歌应用引擎: unitest works nosetest fails

python - Nose 不运行测试

python - 乘以行并按单元格值附加到数据框

python - 从 python 脚本中获取 Flattr 交易?