Repository: nose-devs/nose2

Issue:
junit-xml always add logs in system_err
This is really strange because logs are typically not outputted in stderr. 
In nosetests we did not have logs in case of successful test but now they are always displayed as system_err. 

May it be possible to output them in system_out instead ?

In the testOutcome handler just replace system_err with this code ...

```python
        system_out = ET.SubElement(testcase, 'system-out')
        system_out.text = string_cleanup(
            '\n'.join(event.metadata.get('logs', '')),
            self.keep_restricted
        )

```

Discussion:

Patch:
diff --git a/nose2/plugins/junitxml.py b/nose2/plugins/junitxml.py
index e61a08b..05cfee6 100644
--- a/nose2/plugins/junitxml.py
+++ b/nose2/plugins/junitxml.py
@@ -164,11 +164,10 @@ class JUnitXmlReporter(events.Plugin):
             skipped.set('message', 'expected test failure')
             skipped.text = msg
 
-        system_err = ET.SubElement(testcase, 'system-err')
-        system_err.text = string_cleanup(
+        system_out = ET.SubElement(testcase, 'system-out')
+        system_out.text = string_cleanup(
             '\n'.join(event.metadata.get('logs', '')),
-            self.keep_restricted
-        )
+            self.keep_restricted)
 
     def _check(self):
         if not os.path.exists(os.path.dirname(self.path)):


Test patch:
diff --git a/nose2/tests/unit/test_junitxml.py b/nose2/tests/unit/test_junitxml.py
index 706daa2..0bb96f0 100644
--- a/nose2/tests/unit/test_junitxml.py
+++ b/nose2/tests/unit/test_junitxml.py
@@ -145,7 +145,6 @@ class TestJunitXmlPlugin(TestCase):
         test(self.result)
         case = self.plugin.tree.find('testcase')
         error = case.find('error')
-        ending = six.u(' \uFFFD\uFFFD')
         assert error is not None
         self.assertRegex(error.text, self.EXPECTED_RE_SAFE)
 
@@ -277,22 +276,22 @@ class TestJunitXmlPlugin(TestCase):
         self.assertEqual(inital_dir,
                          os.path.dirname(os.path.realpath(self.plugin.path)))
 
-    def test_xml_contains_empty_system_err_without_logcapture(self):
+    def test_xml_contains_empty_system_out_without_logcapture(self):
         test = self.case('test_with_log')
         test(self.result)
         case = self.plugin.tree.find('testcase')
-        system_err = case.find('system-err')
-        assert system_err is not None
-        assert not system_err.text
+        system_out = case.find('system-out')
+        assert system_out is not None
+        assert not system_out.text
 
-    def test_xml_contains_log_message_in_system_err_with_logcapture(self):
+    def test_xml_contains_log_message_in_system_out_with_logcapture(self):
         self.logcapture_plugin = logcapture.LogCapture(session=self.session)
         self.logcapture_plugin.register()
 
         test = self.case('test_with_log')
         test(self.result)
         case = self.plugin.tree.find('testcase')
-        system_err = case.find('system-err')
-        assert system_err is not None
-        assert 'log message' in system_err.text
-        assert 'INFO' in system_err.text
+        system_out = case.find('system-out')
+        assert system_out is not None
+        assert 'log message' in system_out.text
+        assert 'INFO' in system_out.text