I think this question has come up before, but I don't know that
there's been a really satisfactory solution.

Many of the doctests have dicts as their output (or worse, contained
embedded in their output).  This can fail from time to time since dict
element order is not guaranteed.  This has been particularly bad in
the conversion to Python 3 since there are significant changes in the
dict implementation itself (in particular Python 3.6 preserves the
insertion order of dictionary keys, which is very nice).

Up 'til now I've been making little test fixes here and there by,
instead of outputting dict object directly, doing something like
sorted((k, v) for k, v in d.items(), key=lambda x: str(x[0]) and then
comparing the sorted list of (key, value) tuples (it also becomes
necessary to convert the keys to str or something similar, since a lot
of types that previously had an ordering in Python 2 are no longer
orderable on Python 3 (e.g. str and int).

Obviously this is ugly, and might be impractical to do in every single case.

Did anyone ever think up a better solution to this?

I'm thinking of maybe going so far as to parsing dict literals out of
the test output and re-ordering them (this can be done reasonably well
using the ast module).  But is it worth it?

Thanks,
Erik

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to