a bug report.
I really like doctest, but sometimes doctest gives a failure when the output
looks absolutely fine to me -- indeed, even after I have gone to considerable
effort to make my documentation match the output perfectly.
http://www.aims.ac.za/~mackay/python...an/Huffman3.py
The above file is an example.
It's self-contained, so you can plop it into emacs and hit C-cC-c to run the
doctests. One of them fails.
The piece of source code concerned is here:
c = []; \
c.append(node(0.5,1,'a')); \
c.append(node(0.25,2,'b')); \
c.append(node(0.125,3,'c')); \
c.append(node(0.125,4,'d')); \
iterate(c) ; reportcode(c) # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
#Symbol Count Codeword
a (0.5) 1
b (0.25) 01
c (0.12) 000
d (0.12) 001
"""
And the output is:
Failed example:
c = []; c.append(node(0.5,1,'a')); c.append(node(0.25,2,'b')); c.append(node(0.125,3,'c')); c.append(node(0.125,4,'d')); iterate(c) ; reportcode(c) # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
Expected:
#Symbol Count Codeword
a (0.5) 1
b (0.25) 01
c (0.12) 000
d (0.12) 001
Got:
<__main__.internalnode instance at 0xb7aee76c>
#Symbol Count Codeword
a (0.5) 1
b (0.25) 01
c (0.12) 000
d (0.12) 001
===================================
I have tried numerous tweaks, and am at a loss. I am wondering whether there
is some big in doctest involving the "#" character in the output.
Or maybe I made some silly mistake.
Any advice appreciated!
Many thanks again to the authors of doctest, it gives a great feeling
to write code in the way that doctest encourages. :-)
David
--
David J.C. MacKay ma****@aims.ac.za 787 9336
http://www.aims.ac.za/~mackay/