0

I'd like to capture the output that nose.run() prints to stdout so I can send it in an email if tests fail. I believe the LogCapture plugin does what I want, so I'm doing:

logcap = nose.plugins.logcapture.LogCapture()
success = nose.run(argv=[".", '-x'], plugins=[logcap])

The documentation for logcapture says that the captured log is saved to the test.capturedLogging attribute. The trouble is I have no idea where that is - it's not on my logcap object above, and nose.run() only returns a boolean.

Is there a way to do what I want?

helgridly
  • 133
  • 8
  • Turns out I was labouring under the misunderstanding that nose prints its outputs to stdout - it actually prints to stderr. I found [this snippet](http://stackoverflow.com/a/616686/2941784) useful, with a change to make it dupe stderr rather than stdout. – helgridly Dec 22 '13 at 21:59
  • You surely can make nose email you on error, but you may benefit dramatically by switching to some sort of Continuous Integration (I like jenkins/nose with xunit combo https://nose.readthedocs.org/en/latest/plugins/xunit.html). You will get nice reports too! – Oleksiy Dec 23 '13 at 19:30
  • Yeah - we're using jenkins for plenty of things, but this is a quick sanity check I threw together before we get a more formal end-to-end test together. – helgridly Dec 24 '13 at 17:56

0 Answers0