[Zope3-checkins]
SVN: zope.testing/trunk/src/zope/testing/testrunner.py
fix bug that kept --auto-color from working when it is
specified as a default
Benji York
benji at zope.com
Wed Jul 18 10:19:15 EDT 2007
Log message for revision 78109:
fix bug that kept --auto-color from working when it is specified as a default
argument; I /think/ I've figured out how to test this; perhaps later
Changed:
U zope.testing/trunk/src/zope/testing/testrunner.py
-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py 2007-07-18 14:06:28 UTC (rev 78108)
+++ zope.testing/trunk/src/zope/testing/testrunner.py 2007-07-18 14:19:15 UTC (rev 78109)
@@ -2015,7 +2015,7 @@
# We use a noop callback because the actual processing will be done in the
# get_options function, but we want optparse to generate appropriate help info
-# for us, so we add the option anyway.
+# for us, so we add an option anyway.
reporting.add_option(
'--auto-color', action="callback", callback=lambda *args: None,
help="""\
@@ -2291,6 +2291,23 @@
]
def get_options(args=None, defaults=None):
+ # Because we want to inspect stdout and decide to colorize or not, we
+ # replace the --auto-color option with the appropriate --color or
+ # --no-color option. That way the subprocess doesn't have to decide (which
+ # it would do incorrectly anyway because stdout wouled be a pipe).
+ def apply_auto_color(args):
+ if '--auto-color' in args:
+ if sys.stdout.isatty():
+ colorization = '--color'
+ else:
+ colorization = '--no-color'
+
+ args[:] = [arg.replace('--auto-color', colorization)
+ for arg in args]
+
+ apply_auto_color(args)
+ apply_auto_color(defaults)
+
default_setup, _ = parser.parse_args(default_setup_args)
assert not _
if defaults:
@@ -2303,18 +2320,6 @@
if args is None:
args = sys.argv
- # Because we want to inspect stdout and decide to colorize or not, we
- # replace the --auto-color option with the appropriate --color or
- # --no-color option. That way the subprocess doesn't have to decide (which
- # it would do incorrectly anyway because stdout wouled be a pipe).
- if '--auto-color' in args:
- if sys.stdout.isatty():
- colorization = '--color'
- else:
- colorization = '--no-color'
-
- args = [arg.replace('--auto-color', colorization) for arg in args]
-
original_testrunner_args = args
args = args[1:]
More information about the Zope3-Checkins
mailing list