> Is there a compelling reason for why the new doctesting insists on > taking indentation into account? And in general in not taking each and > every multiline string in the file as a docstring where to get > doctests from? >
The reason is to be able to identify what function is being tested: when a new indentation occurs we check the previous line for the function definition and extract the function name. In sage.doctest.util you'll find a class NestedName (used in sage.doctest.sources in various places in the qualified_name attribute), which is updated when indentation changes. These qualified_names are then printed when a failure occurs. This approach is still not quite robust enough (see #14327) and I would welcome improvements that allowed doctests to be included in more places. I think the above syntax should be supported. Also, I like to be able > to test attributes in classes by prepending a docstring with doctests: > > class blah: > ... > > > """ > TESTS:: > > sage: blah.foo > 3 > """ > foo = 3 > > This is not anymore possible. Finally, with the new global options, > it's natural to feed documentation to the option parser as strings, > and those strings contain examples. We would want them to be tested! > (see sage.combinat.partitions). > As Travis mentions, doctests that are inserted into __doc__ in some other way are not currently tested; this is the subject of #14272. > This is holding up #2023 and #4327, so a quick answer - if not fix - > would be welcome! A minimal change that would cover partitions, > tableaux and the above patches with minimal workaround would be: > diff --git a/sage/doctest/sources.py b/sage/doctest/sources.py > --- a/sage/doctest/sources.py > +++ b/sage/doctest/sources.py > @@ -967,7 +967,7 @@ class PythonSource(SourceLanguage): > quotematch = None > if self.quotetype is None: > # We're not inside a triple quote > - if line[indent] != '#' and (indent == 0 or indent > > self.last_indent): > + if line[indent] != '#' and (indent == 0 or indent >= > self.last_indent): > This change by itself would probably break the printing of the function in which an error occurs (I think it will erase the class name). You probably need to handle the case of equal indentation separately. > I am happy to make this into a ticket. > Cool, though it may be able to go on one of the tickets I mentioned above. I'm not going to have time to work on this soon, but am happy to provide advice. David -- 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 http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.