[Python-Dev] Doctest and Footnotes

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Jul 11 20:37:37 CEST 2006


On 7/11/06, Fred Drake <fred at zope.com> wrote:
> On Tuesday 11 July 2006 14:12, Alexander Belopolsky wrote:
>  > Also __new__ and __init__ method docstrings is the natural place to
>  > put set-up code.
>
> Maybe, if all the tests required the same setup code.  That's often not the
> case.

That's true, but you cannot test an object method without creating the
object first.  For the main cases you would want the object definition
close to the test for the benefit of people who do pydoc Foo.bar, but
for corner cases it is better to have a predefined set of exotic
objects available under descriptive names.  I am also advocating
__init__ docstring because in my use-cases it rarely much of
documentation because object construction is documented in the class
docstring, therefore test set-up code placed in __init__ docstring is
unlikely to clobber often-used documentation.


More information about the Python-Dev mailing list