9

虽然我知道这可以从命令行完成nosetests --nocapture test.py

我想知道是否可以添加代码test.py,这样我就可以在nosetests test.py不添加--nosecapture.

4

2 回答 2

8

您可以通过将-s标志添加到终端命令来查看打印语句。例如

$ nosetests -s test.py

-s, --nocapture

不要捕获标准输出(将立即打印任何标准输出)[NOSE_NOCAPTURE]。

在这里查看官方文档

于 2017-03-28T21:38:13.847 回答
7

You can do it by either defining environment NOSE_NOCAPTURE variable, creating .noserc or nose.cfg file in your home directory that will have something like:

[nosetests]
nocapture=1

or by passing arguments to nose directly in python when calling nose.run() as described in nose documentation

于 2013-11-01T15:52:48.307 回答