[Python-3000] doctest portability
Stefan Behnel
stefan_ml at behnel.de
Sun Jun 1 15:18:26 CEST 2008
Hi,
Nick Coghlan wrote:
> Doctest just uses 'exec' under the covers though - the only way for it
> to run code using non-native syntax would be for it to be able to invoke
> a non-native parser and then run the resulting AST directly, or for it
> to invoke 2to3 on the docstring.
I think it should do the latter.
> Sphinx (the tool used to build the Python docs) gets around this by
> allowing code to be included in the doc source that is used when running
> the doctests, but hidden when generating output for human consumption
> (HTML, PDF, etc)
That's what I do, too, in a couple of places, e.g. to import StringIO/BytesIO
or to make unicode() available. But having to copy syntax work-around code
into each source file that has doctests is the wrong trade-off, IMHO. This
should be an external option passed to the doctest run.
Stefan
More information about the Python-3000
mailing list