Get rid of doctest.py in zope.testing? (Was: Bootstrapping ZCA for Python 3.)
I started a new branch for porting zope.testing to Python 3, for several reasons, mostly because I got confused and decided starting over with a clean copy and beginning with the new Distribute python 3 support from start would make me less foncused (it worked). The branches aren't that different in the end, obviously: http://svn.zope.org/zope.testing/branches/regebro-python3-reloaded/ There are 19 tests that doesn't pass yet (and that's mostly doctest tests, so there are many actual failures), and most of those are based in formatting differences when it comes to doctests. For example: Exceptions in Python 3 print out the whole module path of the exception, while in Python 2 it's only the classname: Immediate doctest failure. This is fixable in your doctests by trapping the exception instead, which is what I've done. However: Many of the failing tests are tests to check that the doctest module works. In the other modules I've ported, the doctest module has been included because it wasn't included in Python 2.3, and could simply be dropped with Python 2.3 support. However, in zope.testing doctests are slightly modified and also tested. So many of the failing tests are tests that doctest behave properly, and that the output formatting is OK. Which, of course, it is not. There are other differences too. The diff module seems to add empty lines at the end sometimes, which bugger up the output, especially in the colorful formatter tests. Efforts to remove doctests failed on the INTERPRET_FOOTNOTES options, which the standard Python doctests doesn't support. A quick search turns out that ZODB, zc.catalog, zc.relation, zc.async, zc.sharing, zc.freeze and lovely.remotetask uses it, maybe more. I really think it's a bad idea to have a special version of doctest.py. I think we should get rid of it. That means either dropping this feature, or getting it merged into Python 2.7 and 3.2. The 2.7 beta is out now, so it's pretty urgent. I strongly suspect it's going to be practically impossible to support zope.testing from the same test-base otherwise. Opinions? -- Lennart Regebro: Python, Zope, Plone, Grok http://regebro.wordpress.com/ +33 661 58 14 64
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Lennart Regebro wrote: <snip>
I really think it's a bad idea to have a special version of doctest.py. I think we should get rid of it. That means either dropping this feature, or getting it merged into Python 2.7 and 3.2. The 2.7 beta is out now, so it's pretty urgent.
Its an alpha, not a beta. http://www.python.org/download/releases/2.7/ says: "Python 2.7 alpha 1 was released on December 5th, 2009." Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAksdckIACgkQ+gerLs4ltQ4HSQCdERMJ05U0yZESlOUhzRpTBnea 5cUAn1B85dN9kj73SRCjWZRIX4b5HRt/ =7Cmh -----END PGP SIGNATURE-----
On Mon, Dec 7, 2009 at 22:23, Tres Seaver <tseaver@palladion.com> wrote:
I really think it's a bad idea to have a special version of doctest.py. I think we should get rid of it. That means either dropping this feature, or getting it merged into Python 2.7 and 3.2. The 2.7 beta is out now, so it's pretty urgent.
Its an alpha, not a beta.
Mistype on my part. If it was a beta it would be too late. :) -- Lennart Regebro: Python, Zope, Plone, Grok http://regebro.wordpress.com/ +33 661 58 14 64
On Mon, Dec 7, 2009 at 4:08 PM, Lennart Regebro <regebro@gmail.com> wrote: ...
I really think it's a bad idea to have a special version of doctest.py.
I agree.
I think we should get rid of it. That means either dropping this feature, or getting it merged into Python 2.7 and 3.2. The 2.7 beta is out now, so it's pretty urgent. I strongly suspect it's going to be practically impossible to support zope.testing from the same test-base otherwise.
Opinions?
It's going to be hard in any case. I sort of see manuel as a replacement for our customized doctest module. I'd change the packages that currently rely on the customizations to not rely on them, either by not using the special features, or by switching to manuel. Whatever we decide is going to be a bit of work. Jim -- Jim Fulton
On Mon, Dec 7, 2009 at 23:12, Jim Fulton <jim@zope.com> wrote:
On Mon, Dec 7, 2009 at 4:08 PM, Lennart Regebro <regebro@gmail.com> wrote: ...
I really think it's a bad idea to have a special version of doctest.py.
I agree.
I think we should get rid of it. That means either dropping this feature, or getting it merged into Python 2.7 and 3.2. The 2.7 beta is out now, so it's pretty urgent. I strongly suspect it's going to be practically impossible to support zope.testing from the same test-base otherwise.
Opinions?
It's going to be hard in any case. I sort of see manuel as a replacement for our customized doctest module. I'd change the packages that currently rely on the customizations to not rely on them, either by not using the special features, or by switching to manuel. Whatever we decide is going to be a bit of work.
OK, I'm going to try to remove doctest.py from my branch, then, and also add some deprecation to it in trunk. On Mon, Dec 7, 2009 at 23:13, Benji York <benji@zope.com> wrote:
On Mon, Dec 7, 2009 at 4:08 PM, Lennart Regebro <regebro@gmail.com> wrote:
For example: Exceptions in Python 3 print out the whole module path of the exception, while in Python 2 it's only the classname: Immediate doctest failure. This is fixable in your doctests by trapping the exception instead, which is what I've done.
You can also use a normalizer. They make dealing with these sorts of inter-Python formatting differences pretty easy.
Hmm. Yeah, a general Python 3 normalizer could maybe be useful. That's worth a try. -- Lennart Regebro: Python, Zope, Plone, Grok http://regebro.wordpress.com/ +33 661 58 14 64
On Mon, Dec 7, 2009 at 23:20, Lennart Regebro <regebro@gmail.com> wrote:
OK, I'm going to try to remove doctest.py from my branch
Done. There are two tests that still fail under Python 2.x: unicode.txt: "There was another unicode bug. When a function returned unicode some internal state switched. This broke any further test not returning unicode but a plain string with unicode characters. Make sure this works now::" Well, it doesn't. testrunner-repeat.txt: The second repetition of the test fails, it seems all local variables suddenly are gone. Loads of "NameError: name 'x' is not defined". No idea how that happened. I assume these are errors fixed in zope.testings copy of doctest, but never in stdlib. Maybe Jim knows? -- Lennart Regebro: Python, Zope, Plone, Grok http://regebro.wordpress.com/ +33 661 58 14 64
On Tue, Dec 8, 2009 at 6:29 AM, Lennart Regebro <regebro@gmail.com> wrote:
On Mon, Dec 7, 2009 at 23:20, Lennart Regebro <regebro@gmail.com> wrote:
OK, I'm going to try to remove doctest.py from my branch
Done. There are two tests that still fail under Python 2.x:
unicode.txt:
"There was another unicode bug. When a function returned unicode some internal state switched. This broke any further test not returning unicode but a plain string with unicode characters. Make sure this works now::"
Well, it doesn't.
testrunner-repeat.txt:
The second repetition of the test fails, it seems all local variables suddenly are gone. Loads of "NameError: name 'x' is not defined". No idea how that happened.
I assume these are errors fixed in zope.testings copy of doctest, but never in stdlib. Maybe Jim knows?
The unicode test relates to a feature that was added to both the stdlib doctest and the zope.testing doctest. This was some time ago. I don't remember any details. I don't recall any special changes in the zope.testing version of doctest to support repetition. Jim -- Jim Fulton
On Tue, Dec 8, 2009 at 12:55, Jim Fulton <jim@zope.com> wrote:
On Tue, Dec 8, 2009 at 6:29 AM, Lennart Regebro <regebro@gmail.com> wrote:
On Mon, Dec 7, 2009 at 23:20, Lennart Regebro <regebro@gmail.com> wrote:
OK, I'm going to try to remove doctest.py from my branch
Done. There are two tests that still fail under Python 2.x:
unicode.txt:
"There was another unicode bug. When a function returned unicode some internal state switched. This broke any further test not returning unicode but a plain string with unicode characters. Make sure this works now::"
Well, it doesn't.
testrunner-repeat.txt:
The second repetition of the test fails, it seems all local variables suddenly are gone. Loads of "NameError: name 'x' is not defined". No idea how that happened.
I assume these are errors fixed in zope.testings copy of doctest, but never in stdlib. Maybe Jim knows?
The unicode test relates to a feature that was added to both the stdlib doctest and the zope.testing doctest. This was some time ago. I don't remember any details.
I don't recall any special changes in the zope.testing version of doctest to support repetition.
OK. I have no clue, it's clearly complex bugs, and I've spent two days on zope.testing already, so I'm taking a break from the Python 3 porting of the ZCA. If anyone wants to dig into these bugs the branch is http://svn.zope.org/zope.testing/branches/regebro-python3-reloaded/ -- Lennart Regebro: Python, Zope, Plone, Grok http://regebro.wordpress.com/ +33 661 58 14 64
On Mon, Dec 7, 2009 at 4:08 PM, Lennart Regebro <regebro@gmail.com> wrote:
For example: Exceptions in Python 3 print out the whole module path of the exception, while in Python 2 it's only the classname: Immediate doctest failure. This is fixable in your doctests by trapping the exception instead, which is what I've done.
You can also use a normalizer. They make dealing with these sorts of inter-Python formatting differences pretty easy.
Efforts to remove doctests failed on the INTERPRET_FOOTNOTES options, which the standard Python doctests doesn't support. A quick search turns out that ZODB, zc.catalog, zc.relation, zc.async, zc.sharing, zc.freeze and lovely.remotetask uses it, maybe more.
Those tests could probably use Manuel's footnote support instead, but that would add one more dependency (Manuel) that would have to be ported to Python 3 -- and I don't have any expectation that I'll be doing that in the near future.
I really think it's a bad idea to have a special version of doctest.py. I think we should get rid of it.
I'd like for them to be unified too, but even ignoring INTERPRET_FOOTNOTES, the two have drifted apart quite a bit. The last time I looked at it I stopped after spending several frustrating hours comparing diffs and trying to get one's tests to run on the other. Maybe you'll have more success than I did. -- Benji York
participants (4)
-
Benji York -
Jim Fulton -
Lennart Regebro -
Tres Seaver