[Python-Dev] doctest, unicode repr, and 2to3

"Martin v. Löwis" martin at v.loewis.de
Fri Mar 5 22:39:30 CET 2010


> The issue shows (yet again) a general problem with doctests being
> overspecified -- the test shouldn't care that the output starts with
> 'u', it should only care that the value is unicode, but there's no
> easy way to express this in doctests. But since these doctests exist I
> suggest that the practical way forward is to stick with them rather
> than trying to reformulate all the tests.

Ok, I think I would prefer that. One approach I considered was to
override sys.displayhook, so that I can determine what parts of the
output are "single" repr results. Of course, this wouldn't catch repr
strings that were ultimately print()ed (not sure whether that
restriction would affect Django).

The other (more aggressive) approach is the heuristics you propose,
which may end up with false negatives. doctest already has a wildcard
matching flag, so it would grow another one.

Regards,
Martin



More information about the Python-Dev mailing list