On Thu, Jan 28, 2010 at 10:06 PM, John H Palmieri
<jhpalmier...@gmail.com> wrote:
> On Jan 28, 9:59 pm, Dima Pasechnik <dimp...@gmail.com> wrote:
>> as discussed recently here in connection with GAP interface, the
>> following looks like an obvious deficiency of docstrings testing: a
>> computation returns a list in some unpredictable order, and docstrings
>> are in another order, even though the corresponding sets are the same.
>>
>> Just sorting the list in Sage does not work, as the object in question
>> has a state maintained by an external program (e.g. GAP), and messing
>> up this order is no fun at all.
>> (well, yes, one can think of maintaining the permutation used for the
>> sorting, etc etc, but this looks like an unnecessary kludge)
>>
>> It seems to me that the right way to deal with this is to extend the
>> capabilities of the testing scheme so that it is able to handle sets,
>> not only lists.
>
> Maybe you can write doctests in one of these forms
>
> sage: set([output from function...]) == set([what the output is
> supposed to be])
> True
>
> (or use Set instead of set?)
>
> sage: (some known element) in [output from function]
> True
>
> sage: convert output to string and do some string comparisons on it
>

+1 to John's suggestion to rewrite your tests so that the lists are
sorted in a sensible way.   There are many ways to do so as he pointed
out.   If we can avoid it, we shouldn't  change the Python doctest
framework any more than we already have (which is very minimal).

We could add a function to Sage for testing purposes, such as:

sage: strsort(v)

which would takes it input (any iterable), convert all entries to
strings, then sort, then output the result as a list.  Then your
doctests would display that output.

It's good to keep in mind that doctests are meant to be viewed by
people, so tests like the above that maybe aren't so human readable
should go in the

TESTS::

section instead of the EXAMPLES:: section.

 -- William

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to