After running into trouble trying to set the python unittest discover pathway for my project, I'm trying again with nose. I am trying to print out verbose output which is supposedly captured by default by Nose (according to http://nose.readthedocs.org/en/latest/plugins/capture.html )
I have:
arg =sys.argv[:1]
arg.append('--verbosity=2')
out = nose.run(module=ft1.test_y1, argv=arg)
but 'out' is a boolean
How can I get it working?
Your best bet would be to disable the plugin and capture standard output with some other means, for example as described here :
import sys
import nose
from cStringIO import StringIO
def basic_test():
print "hello"
if __name__=="__main__":
module_name = sys.modules[__name__].__file__
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
result = nose.run(argv=[sys.argv[0],
module_name,
'-s'])
sys.stdout = old_stdout
print mystdout.getvalue()
When running it like this you will get:
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
hello
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.