[TIP] Docstrings in Test methods

Alfredo Deza alfredodeza at gmail.com
Sat Nov 5 09:30:24 PDT 2011

On Sat, Nov 5, 2011 at 10:23 AM, Ned Batchelder <ned at nedbatchelder.com> wrote:
> On 11/5/2011 9:05 AM, Mike Pirnat wrote:
>> I work in a pretty big codebase with a lot of developers.  We prefer
>> not having a docstring on our tests so that when they do fail, we can
>> quickly identify what test it is (and who the best people to fix it
>> are going to be).
>> Our compromise in the sake of explaining a test is to use a comment
>> where we would otherwise have a docstring in production code.
>> I would be all for using docstrings for consistency with our
>> production code if the test runner wouldn't replace the test
>> module/class/method with the docstring in its output.
> I completely agree.  I use comments in test methods rather than docstrings.
> BTW: the line from my slides was about product code, not test code:
>  Sometimes a real stumbling block to testing is that you have to decide what
> your product code actually does.  Once you figure that out, it's a good idea
> to write it down in the docstrings.

Ah, I knew that this could be read in that sense as well. At least,
when Michael Foord discussed
this one slide with me he thought the same.

> --Ned.

More information about the testing-in-python mailing list