[Distutils] zc.recipe.testrunner hook?
Barry Warsaw
barry at python.org
Mon Jan 5 21:08:22 CET 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm not sure this is the best place to ask about zc.recipe.testrunner,
but I will anyway :).
Besides converting to zc.buildout, over my recent forced vacation, I
also converted Mailman 3 to zc.recipe.testrunner. This is another bit
of awesome from Zope I'm glad to be using.
One small problem though: I need to hook into the option parser to add
a few more options. For example, I'm adding a -e/--stderr option
which sets up logging propagation for some of my subprocess tests.
The way I've done it is to add this to my buildout.cfg file:
[test]
recipe = zc.recipe.testrunner
...
# Hack in extra arguments to zope.testrunner.
initialization = from mailman.testing.layers import ConfigLayer;
ConfigLayer.hack_options_parser()
The hack_options_parser() method looks like this:
def hack_options_parser(cls):
"""Hack our way into the zc.testing framework.
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!
"""
from zope.testing.testrunner.options import parser
parser.add_option('-e', '--stderr',
action='callback',
callback=cls.handle_stderr,
help=_('Propagate log errors to stderr.'))
So as the comment asks passive-aggressively: is there a better way?
Thanks,
Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
iQCVAwUBSWJotnEjvBPtnXfVAQJvbwP+NkKyX9bYWLrZQ4L4b3wWbCfL9l72EyQi
RJh0EPQn1Efz6Oe7h+oTojbGxmpviHyJl+OnrO3OrwPxR5miXK3dWFmtdh7r/TUm
jRz3m4k58UwVe2/uWnlHGQ4c/4ooBP0kYZecwTms2cUtzZFkVF/IUoSPvJl/80R2
5q1ZBq9P5PE=
=pUiS
-----END PGP SIGNATURE-----
More information about the Distutils-SIG
mailing list