""" This plugin captures stdout during test execution. If the test fails or raises an error, the captured output will be appended to the error or failure output. It is enabled by default but can be disabled with the options ``-s`` or ``--nocapture``.
:Options: ``--nocapture`` Don't capture stdout (any stdout output will be printed immediately)
"""
""" Output capture plugin. Enabled by default. Disable with ``-s`` or ``--nocapture``. This plugin captures stdout during test execution, appending any output captured to the error or failure output, should the test fail or raise an error. """
"""Register commandline options """ "-s", "--nocapture", action="store_false", default=not env.get(self.env_opt), dest="capture", help="Don't capture stdout (any stdout output " "will be printed immediately) [NOSE_NOCAPTURE]")
"""Configure plugin. Plugin is enabled by default. """ self.enabled = False
"""Clear capture buffer. """
"""Replace sys.stdout with capture buffer. """
"""Flush capture buffer. """
"""Add captured output to error report. """ test.capturedOutput = output = self.buffer self._buf = None if not output: # Don't return None as that will prevent other # formatters from formatting and remove earlier formatters # formats, instead return the err we got return err ec, ev, tb = err return (ec, self.addCaptureToErr(ev, output), tb)
"""Add captured output to failure report. """ return self.formatError(test, err)
ev = exc_to_unicode(ev) output = force_unicode(output) return '\n'.join([ev, ln('>> begin captured stdout <<'), output, ln('>> end captured stdout <<')])
"""Restore stdout. """
if self._buf is not None: return self._buf.getvalue()
"""Captured stdout output.""") |