diff options
| author | Barry Warsaw | 2010-06-18 19:23:35 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2010-06-18 19:23:35 -0400 |
| commit | b3e874703bce97c121eb97dd9776da15a8b90070 (patch) | |
| tree | 9d884eeb4c6fd4a5e7aad8e96ced642f57ecc7ac /src/mailman/testing/layers.py | |
| parent | f4e7637b1682f025cc6c8bfb172eda8b710e3218 (diff) | |
| download | mailman-b3e874703bce97c121eb97dd9776da15a8b90070.tar.gz mailman-b3e874703bce97c121eb97dd9776da15a8b90070.tar.zst mailman-b3e874703bce97c121eb97dd9776da15a8b90070.zip | |
Diffstat (limited to 'src/mailman/testing/layers.py')
| -rw-r--r-- | src/mailman/testing/layers.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py index e7907b172..34dc46807 100644 --- a/src/mailman/testing/layers.py +++ b/src/mailman/testing/layers.py @@ -197,22 +197,25 @@ class ConfigLayer(MockAndMonkeyLayer): stderr = False @classmethod - def handle_stderr(cls, *ignore): - cls.stderr = True + def enable_stderr(cls): + """Enable stderr logging if -e/--stderr is given. - @classmethod - def hack_options_parser(cls): - """Hack our way into the zc.testing framework. + We used to hack our way into the zc.testing framework, but that was + undocumented and way too fragile. Well, this probably is too, but now + we just scan sys.argv for -e/--stderr and enable logging if found. + Then we remove the option from sys.argv. This works because this + method is called before zope.testrunner sees the options. - Add our custom command line option parsing into zc.testing's. We do - the imports here so that if zc.testing isn't invoked, this stuff never - gets in the way. This is pretty fragile, depend on changes in the - zc.testing package. There should be a better way! + As a bonus, we'll check an environment variable too. """ - from zope.testing.testrunner.options import parser - parser.add_option(str('-e'), str('--stderr'), - action='callback', callback=cls.handle_stderr, - help=_('Propagate log errors to stderr.')) + if '-e' in sys.argv: + cls.stderr = True + sys.argv.remove('-e') + if '--stderr' in sys.argv: + cls.stderr = True + sys.argv.remove('--stderr') + if len(os.environ.get('MM_VERBOSE_TESTLOG', '').strip()) > 0: + cls.stderr = True |
