[Zope-dev] zope.test.doctest made into monkey-patches (Was: Circular dependency hell.)

Lennart Regebro regebro at gmail.com
Wed Apr 21 01:10:38 EDT 2010


On Tue, Apr 20, 2010 at 20:35, Jim Fulton <jim at zope.com> wrote:
> Monkey patching should be used as a last resort. Monkey
> patching the standard library is likely to make us look like
> jack asses.

Possibly. But having a doctest module with loads of bugs that doesn't
even behave exactly the same maybe doesn't make us look like
jackasses, but it sure as heck is a big pain, and makes zope.testing
practically impossible to port to Python 3 in a sensible way. The
monkey-patching makes it possible to remove the doctest module without
all of zopes.* tests failing. The Deprecation warning of course should
remain.

It can be noted that my previous Python 3 porting efforts have simply
deleted the doctest module. I believe these are the two options we
have if we want ZTK to be ported to Python 3. So it's really a choice:
Delete it and monkey patch, or delete it and break everything, or not
supporting Python 3.

> We should switch to manuel, which already has the footnote feature.

Oh, I'm *not* monkey-patching in the footnote feature. :) People using
that feature will have to stay with an earlier zope.testing or switch
to Manuel.

> Let zope.testing.doctest wither and die

It hasn't been merged from python trunk since 2004, and the amount of
bugfixes on that Python trunk since then is astounding. So I'd argue
that is *is* withered. The monkey-patching kills it. :)

Interestingly, there are two bugs fixed on zopes doctest that hasn't
been fixed in the standard library. I've reported them:

http://bugs.python.org/issue8471
http://bugs.python.org/issue8473

So that's two of the patches. The remaining two patches are:

1. zope doctests get the TestCases surrounding environment, while
stdlib doctests you need to explicitly pass in extra environment. That
patch is there for compatibility, some tests won't work otherwise.

2. stdlibs unittest will ignore all reporting flags given to the
testrunner if any reporting flag is given to the test, most
significantly also the -1 flag. I think that's daft, so I took it up
on python-dev.

Lastly doctest.DocTestCase.failureException is set to
zope.testing.exceptions.DocTestFailureException, but that's not even a
monkey-patch, that's how you are supposed to do it, so that's a part
of the testrunner, really, and probably that "patching" should be done
by the testrunner before it runs the tests instead, should be a simple
fix.

-- 
Lennart Regebro: Python, Zope, Plone, Grok
http://regebro.wordpress.com/
+33 661 58 14 64


More information about the Zope-Dev mailing list