nose-devs/nose — pull request #564 by jszakmeister (2012-10-02 19:39:21+00:00)
Title: Teach xunit to capture stdout...

One long standing issue with the xunit plugin is that it does not capture stdout and put it into the resultant xml file. We'd really like to have that output, so I took a stab at implementing. It was rather tricky, particularly with how to adjust the scores, but here's an implementation that passes all the tests.

A couple of notes on the implementation. I wanted to preserve the use of `-s` for the capture plugin. Meaning, despite xunit wanting to capture stdout, I still wanted output to show up on the console when the user asks for it. So I put a Tee object to help split the stream, so that it'll write to the internal StringIO and sys.stdout.

The only thing I don't like about my approach is having to adjust scores on a few plugins. But it felt less hackish than, say, creating a simple plugin to help workaround the ordering of capture and xunit, and then having the xunit plugin depend on it.

All the tests pass with this, FWIW. If you like the approach, I can add an option to disable the capturing of stdout in the XML file, or vice versa, add an option to enable capturing it. I imagine there are some users out there who don't want it. I just didn't want to spend too much more time on this without bouncing it off of you first.