On Tue, Jun 19, 2012 at 12:36 AM, Aaron Meurer <[email protected]> wrote: > I think the problem is not that you are adding the docstring manually > but that you are adding them to instances. The doctest runner only > checks classes and functions for doctests. > > However, I was looking through the doctest runner to verify this, and > I found a solution, which is not currently used anywhere in the > codebase. If you define a dictionary at the module level called > __test__ like > > __test__ = {'R2': R2.__doc__, ...} > > Then the doctest runner will test it. You can doctest any string with > this method. I'm sending in a small patch that fixes a minor semantic > about it, but the method seems to work just fine.
Actually, I'm going to leave it be, because it's consistent with the built-in doctest runner. What I was going to change was that __test__ doctests are printed as module.__test__.object, which doesn't make sense (it's not an attribute of __test__, it's a key). Also, I was going to change it to __doctest__, but it seems that __test__ is already in common use, so I'll leave that too. Aaron Meurer > > Aaron Meurer > > On Fri, May 18, 2012 at 2:01 PM, [email protected] > <[email protected]> wrote: >> Can one run doctests on modified docstrings: >> >> ``` >> class ClassWithDocstring(object) >> """Blah Blah and doctests.""" >> pass >> >> instance_with_docstring = ClassWithDocstring() >> instance_with_docstring.__doc__ = """Blah blah and other doctests""" >> ``` >> >> The doctests in instance_with_docstring.__doc__ are not checked. >> >> The reason I am doing this is that I have a Manifold class but also >> predefined Manifold instances for stuff like R^2 and R^3. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sympy" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/sympy?hl=en. >> -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
