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 tested:<div>

<br></div><div>import doctest</div><div><br></div><div>def _compare(got, expected):</div><div>    return (sorted(eval(got)) == sorted(eval(expected)) or</div><div>        doctest.compare(got, expected))</div><div><br></div>

<div>doctest.usercompare = _compare</div><div><br></div><div>The compare function would only need to deal with the idiosyncrasies of types actually used in doctests in that module.</div><div><br></div><div>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!  </div>

<div><br></div><div>David</div><div><br><div class="gmail_quote">On Fri, Mar 2, 2012 at 7:36 AM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">Steven D'Aprano wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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_<u></u>output, perhaps something like this:<br>
<br>
<br>
if optionflags & IGNORE_WORD_ORDER:<br>
    if sorted(got.split()) == sorted(want.split()):<br>
        return True<br>
</blockquote>
<br></div>
Ah, buggarit, too simple. I neglected to take into account the delimiters.<br>
<br>
Getting this right is harder than I thought, particularly with nested sets/dicts.<br>
<br>
Still, I reckon a directive is the right approach.<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
-- <br>
Steven<br>
<br>
______________________________<u></u>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br></div>