aquavitae69 at gmail.com
Fri Mar 2 06:56:55 CET 2012
It seems that the problem with any solution based on interpreting repr
(especially when nothing in know about the object) is that there are just
too many exceptions. Another approach might be to allow for a custom
compare function to be defined on doctest. E.g., in the module to be
def _compare(got, expected):
return (sorted(eval(got)) == sorted(eval(expected)) or
doctest.usercompare = _compare
The compare function would only need to deal with the idiosyncrasies of
types actually used in doctests in that module.
I don't know how practical this idea is in terms of implementation - from
my brief look through the code I think it should be fairly easy to slot
this into OutputChecker, but it was a very brief look!
On Fri, Mar 2, 2012 at 7:36 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> Steven D'Aprano wrote:
> This approach doesn't try to be too clever: it's a dumb, understandable
>> test which should fit in nicely with the other tests in
>> doctest.OutputChecker.check_**output, perhaps something like this:
>> if optionflags & IGNORE_WORD_ORDER:
>> if sorted(got.split()) == sorted(want.split()):
>> return True
> Ah, buggarit, too simple. I neglected to take into account the delimiters.
> Getting this right is harder than I thought, particularly with nested
> Still, I reckon a directive is the right approach.
> Python-ideas mailing list
> Python-ideas at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas