[Python-3000] doctest portability

Georg Brandl g.brandl at gmx.net
Sat May 31 17:13:38 CEST 2008


Stefan Behnel schrieb:
> Hi,
> 
> I currently use a bunch of work-arounds for doctests in lxml's test suite to
> make them work in Py3. I converted most tests to a mix of Py2 and Py3 syntax
> (e.g. using both u'' and b'' literals), and most of the runtime work is done
> using regular expressions that convert the except-as syntax, strip package
> names from tracebacks and translate bytes/str output between Py2 and Py3
> syntax/repr.
> 
> I know, I could use the lib2to3 package, but it a) is a one-way tool in the
> wrong direction if you have to distinguish bytes/str literals, b) lacks
> configurability stating exactly what changes need to be done and c) seemed
> harder to set up for doctests than doing the conversion by hand.

Shouldn't the -d option handle doctests without further set-up?

Georg


-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-3000 mailing list