I am using the python extension unittest, unittest-xml-reporting . It currently writes stdout and saves it in the output xml file. Awesome! But I also want to give it to the screen, so I do not need to view this file every time I run my test suite. Two main functions:
def _patch_standard_output(self):
"""Replace the stdout and stderr streams with string-based streams
in order to capture the tests' output.
"""
(self.old_stdout, self.old_stderr) = (sys.stdout, sys.stderr)
(sys.stdout, sys.stderr) = (self.stdout, self.stderr) = \
(StringIO(), StringIO())
def _restore_standard_output(self):
"Restore the stdout and stderr streams."
(sys.stdout, sys.stderr) = (self.old_stdout, self.old_stderr)
I tried to remove
(sys.stdout, sys.stderr) = (self.stdout, self.stderr) = (StringIO(), StringIO())
and replace it with
(self.stdout, self.stderr) = (StringIO(), StringIO())
but then he did not add it to the xml file. Any help is appreciated. I will be happy to submit a pull request when I earn it too!
source
share