diff --git a/nose/__version__.py b/nose/__version__.py index a70f571..4cbf7d6 100755 --- a/nose/__version__.py +++ b/nose/__version__.py @@ -1,2 +1,2 @@ # pynose nose package -__version__ = "1.4.7" +__version__ = "1.4.8" diff --git a/nose/plugins/capture.py b/nose/plugins/capture.py index c0b7ffd..07e350f 100644 --- a/nose/plugins/capture.py +++ b/nose/plugins/capture.py @@ -1,12 +1,14 @@ -"""This plugin captures stdout during test execution. If the test fails +"""This plugin captures stdout during test execution. If a 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``. +or failure output. It is disabled by default, but can be enabled with +the options: ``--capture-output`` or ``--capture_output``. +Or enable it by setting os.environ["NOSE_CAPTURE"] to "1". :Options: - ``--nocapture`` - Don't capture stdout (any stdout output will be printed immediately) """ + ``--capture-output`` or ``--capture_output`` + Capture stdout (stdout output will not be printed) """ import logging +import os import sys from nose.plugins.base import Plugin from nose.pyversion import exc_to_unicode, force_unicode @@ -17,10 +19,9 @@ 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.""" + """Output-capturing plugin. Now disabled by default. + Can be enabled with ``--capture-output`` or ``--capture_output``. + Or enable it with os.environ["NOSE_CAPTURE"]="1" before tests.""" enabled = True name = "capture" score = 1600 @@ -37,11 +38,24 @@ def options(self, parser, env): help="Don't capture stdout (any stdout output " "will be printed immediately) [NOSE_NOCAPTURE]" ) + parser.add_option( + "--capture-output", "--capture_output", action="store_true", + default=False, dest="capture_output", + help="Capture stdout (stdout output " + "will not be printed) [NOSE_CAPTURE]" + ) def configure(self, options, conf): """Configure plugin. Plugin is enabled by default.""" self.conf = conf - if not options.capture: + if ( + "NOSE_CAPTURE" in os.environ.keys() + and os.environ["NOSE_CAPTURE"] == "1" + ): + self.enabled = True + elif options.capture_output: + self.enabled = True + elif not options.capture: self.enabled = False def afterTest(self, test):