David MacKay wrote: > 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.
> 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: You have to suppress the return value of iterate() dummy = iterate(c); reportcode(c) > +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: > > Expected: > #Symbol Count Codeword > a (0.5) 1 > Got: > <__main__.internalnode instance at 0xb7aee76c> This is the result of iterate(c). The interactive interpreter ignores None return values but prints the repr() of everything else. doctest emulates that behaviour. Peter -- http://mail.python.org/mailman/listinfo/python-list