/usr/lib/python2.6/site-packages/nose/plugins
NameSizeModeActions
attrib.py78100644editdlrm
attrib.pyc74280644editdlrm
attrib.pyo74280644editdlrm
base.py313840644editdlrm
base.pyc368100644editdlrm
base.pyo368100644editdlrm
builtin.py7920644editdlrm
builtin.pyc13690644editdlrm
builtin.pyo13690644editdlrm
capture.py27800644editdlrm
capture.pyc45650644editdlrm
capture.pyo45650644editdlrm
cover.py64160644editdlrm
cover.pyc62130644editdlrm
cover.pyo62130644editdlrm
debug.py16790644editdlrm
debug.pyc24810644editdlrm
debug.pyo24810644editdlrm
deprecated.py16390644editdlrm
deprecated.pyc23850644editdlrm
deprecated.pyo23850644editdlrm
doctests.py91470644editdlrm
doctests.pyc98910644editdlrm
doctests.pyo98910644editdlrm
errorclass.py64380644editdlrm
errorclass.pyc80370644editdlrm
errorclass.pyo80370644editdlrm
failuredetail.py15640644editdlrm
failuredetail.pyc23340644editdlrm
failuredetail.pyo23340644editdlrm
isolate.py36740644editdlrm
isolate.pyc47290644editdlrm
isolate.pyo47290644editdlrm
manager.py143300644editdlrm
manager.pyc183700644editdlrm
manager.pyo183700644editdlrm
plugintest.py79940644editdlrm
plugintest.pyc96440644editdlrm
plugintest.pyo96440644editdlrm
prof.py47440644editdlrm
prof.pyc49330644editdlrm
prof.pyo49330644editdlrm
skip.py15720644editdlrm
skip.pyc22890644editdlrm
skip.pyo22890644editdlrm
testid.py48710644editdlrm
testid.pyc54790644editdlrm
testid.pyo54790644editdlrm
__init__.py81690644editdlrm
__init__.pyc84120644editdlrm
__init__.pyo84120644editdlrm
Edit: /usr/lib/python2.6/site-packages/nose/plugins/capture.py (2780B)
""" 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. It is enabled by default but may be disable with the options -s or --nocapture. """ import logging import os import sys from nose.plugins.base import Plugin from nose.util import ln try: from cStringIO import StringIO except ImportError: from StringIO import StringIO log = logging.getLogger(__name__) class Capture(Plugin): """ 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. """ enabled = True env_opt = 'NOSE_NOCAPTURE' name = 'capture' score = 500 def __init__(self): self.stdout = [] self._buf = None def options(self, parser, env=os.environ): parser.add_option( "-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]") def configure(self, options, conf): self.conf = conf if not options.capture: self.enabled = False def afterTest(self, test): self.end() self._buf = None def begin(self): self.start() # get an early handle on sys.stdout def beforeTest(self, test): self.start() def formatError(self, test, err): 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) def formatFailure(self, test, err): return self.formatError(test, err) def addCaptureToErr(self, ev, output): return '\n'.join([str(ev) , ln('>> begin captured stdout <<'), output, ln('>> end captured stdout <<')]) def start(self): self.stdout.append(sys.stdout) self._buf = StringIO() sys.stdout = self._buf def end(self): if self.stdout: sys.stdout = self.stdout.pop() def finalize(self, result): while self.stdout: self.end() def _get_buffer(self): if self._buf is not None: return self._buf.getvalue() buffer = property(_get_buffer, None, None, """Captured stdout output.""")