On Wed, Nov 3, 2010 at 1:01 AM, Stefan Behnel <[email protected]> wrote:
> Robert Bradshaw, 03.11.2010 08:26:
>> On Tue, Nov 2, 2010 at 4:17 AM, Lisandro Dalcin wrote:
>>> On 2 November 2010 11:49, Stefan Behnel wrote:
>>>> Robert Bradshaw, 01.11.2010 21:44:
>>>>> On Sun, Oct 31, 2010 at 11:38 AM, Stefan Behnel wrote:
>>>>>>> One problem I spotted was the auto test dict (again).
>>>>>>
>>>>>> I simplified it now to use the compile time docstrings directly, instead 
>>>>>> of
>>>>>> looking them up at runtime. I don't think this breaks anything important,
>>>>>> as the docstrings of functions and methods cannot be modified anyway. On
>>>>>> the plus side, it removes a *ton* of ugly C code, and also saves some 
>>>>>> time
>>>>>> during module initialisation.
>>>>>
>>>>> Excellent! I've been wanting to do this myself, eventually when I
>>>>> found the time. This means that cdef methods could have tested
>>>>> docstrings as well (though, of course, they couldn't be called
>>>>> directly).
>>>>
>>>> That was easy to implement, so I tried it. In lxml.etree, it adds some 10KB
>>>> to the size of the module source code as the docstrings of cdef functions
>>>> wouldn't otherwise end up there. Personally, I'm not sure it's worth it. If
>>>> you can't call a cdef function/method from a doctest directly, why not just
>>>> move the doctest itself to the function or method that you would have to
>>>> call anyway?
>>>
>>> I agree with Stefan.
>>
>> Sometimes I have a doctest in, e.g., a class body docstring to
>> (indirectly) test a cdef method.
>
> Hmm, but putting that doctest into the cdef method's docstring would still
> test it through the class, i.e. it would test the interface of the class,
> not just the cdef method.
>
> I think this is really just a minor issue.

I agree.

>> On this note,
>> would it be easy/feasible to only insert docstrings that actually have
>> tests in them?
>
> I thought about that, too. You could easily check for ">>> " being in the
> text, that would pretty clearly hint towards a doctest. However, leaving
> everything else out means that it's impossible to run non-doctest based
> docstring tests, e.g. by just putting some kind of test data into the
> docstrings.
>
> What about restricting it to docstrings containing ">>> " by default and
> adding another directive like "autotestdict.all" to include all docstrings?
>
> Maybe also "autotestdict.cdef" to include matching cdef function/method
> docstrings in addition to the matching Python functions?
>
>    autotestdict (default) < autotestdict.cdef < autotestdict.all
>
> I think that would basically cover all use cases, including the less common
> ones.

+1. Dotted directives are already supported.

- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to