nose-devs/nose — pull request #736 by yakxxx (2013-10-03 13:29:31+00:00)
Title: Xunit output capture fix

Xunit plugin captures `stdout` and `stderr` and attaches it to generated xml file. To manage it it monkey-patches `sys.stdout` and `sys.stderr`. This monkey patching is done after module was loaded and replayed before every test. This approach makes it incompatible with python `logging` library.

When we use logging library either in test itself or in tested part of code typical approach would be to create `StreamHandler` only once and then to use this handler. It means that `StreamHandler` is carrying it's own reference to stderr and is not using `sys.stderr` before every write to stderr.

Please consider this example:

```
import unittest
import logging
logging.basicConfig()

class T(unittest.TestCase):
def test_a(self):
logging.error('ERROR')
```

This 'ERROR' string won't be captured by Xunit plugin because `logging` was initialized on module import and `sys.stderr` was monkey-patched after it.