Lennart Regebro
2009-01-05 13:27:13 UTC
I've encountered two problems concerning doctests, which I nowadays
therefore like even less than before. ;-)
Problem number one:
When raising exceptions under 2.x, the last line of the error message
will look something like this:
ExceptionClass: The message
But under 3.0 it will look thusly:
module.ExceptionClass: The message
This means that the typical doctest pattern of:
Traceback (most recent call last):
...
ExceptionClass: The message
will fail. And I haven't been able to make a pattern that will work.
Sticking ... in front of ExceptionClass doesn't. What is the best way
to get around this? I could to a try/except in the doc test code and
raise an assertion error of the exception is not raised, but that's
UGLY.
Problem number two:
When porting iCalendar, the UTF-8 encoded data that should be returned
for interchange will be a string in Python2, but bytes in Python3.
Hence,
I haven't found any reasonable way around that, making support for 2.5
and 3.0 from the same code base (even with 2to3) impossible.
Any ideas?
therefore like even less than before. ;-)
Problem number one:
When raising exceptions under 2.x, the last line of the error message
will look something like this:
ExceptionClass: The message
But under 3.0 it will look thusly:
module.ExceptionClass: The message
This means that the typical doctest pattern of:
Traceback (most recent call last):
...
ExceptionClass: The message
will fail. And I haven't been able to make a pattern that will work.
Sticking ... in front of ExceptionClass doesn't. What is the best way
to get around this? I could to a try/except in the doc test code and
raise an assertion error of the exception is not raised, but that's
UGLY.
Problem number two:
When porting iCalendar, the UTF-8 encoded data that should be returned
for interchange will be a string in Python2, but bytes in Python3.
Hence,
foo()
"bar"foo()
b"bar"I haven't found any reasonable way around that, making support for 2.5
and 3.0 from the same code base (even with 2to3) impossible.
Any ideas?
--
Lennart Regebro: Zope and Plone consulting.
http://www.colliberty.com/
+33 661 58 14 64
Lennart Regebro: Zope and Plone consulting.
http://www.colliberty.com/
+33 661 58 14 64