Python doctests / sphinx : style guide, how to use those and have a readable code ?

Posted by Sébastien Piquemal on Stack Overflow See other posts from Stack Overflow or by Sébastien Piquemal
Published on 2010-05-25T06:28:02Z Indexed on 2010/05/25 6:31 UTC
Read the original article Hit count: 225

Filed under:
|
|
|
|

Hi !

I love doctests, it is the only testing framwork I use, because it is so quick to write, and because used with sphinx it makes such great documentations with almost no effort...

However, very often, I end-up doing things like this :

"""
Descriptions
=============

bla bla bla ...

    >>> test
    1
bla bla bla + tests tests tests * 200 lines = poor readability of the actual code
"""

What I mean is that I put all my tests with documentation explanations on the top of the module, so you have to scroll stupidly to find the actual code, and this is quite ugly (in my opinion). However, I think that the doctests should still stay in the module, because you should be able to read them while reading the source code. So here comes my question : sphinx/doctests lovers, how do you organize your doctests, such as the code readability doesn't suffer ?

© Stack Overflow or respective owner

Related posts about python

Related posts about sphinx