[melbourne-pug] doctest: can you distinguish between a test & a variable setting?

Mohamed Barwani minnov at gmail.com
Thu Mar 26 01:41:31 CET 2009


Hi all,

I like doctest but when you have complex arguments that you need to
set before you pass to a function it become really hard to read..
Hence, you start using multiple lines assigning then calling the
function that you would like to test.. This approach however, will
report that you have multiple tests rather then the real number of
tests that you have.. An example will illustrate what I mean..

def returnme(x):
    """
    Returns what you pass

    >>> y = (2, 3, 5, 7)
    >>> returnme(y)
    (2, 3, 5, 7)
    """
    return x

In the above snippet, there is only one test and the other is just a
variable assignment, however, this is what gets reported..

Trying:
    y = (2, 3, 5, 7)
Expecting nothing
ok
Trying:
    returnme(y)
Expecting:
    (2, 3, 5, 7)
ok
<snip>
2 tests in 2 items.
2 passed and 0 failed.

I've looked at the flags documented, surely I missing something..

-- 
Democracy divides people into workers and loafers. It makes no
provision for those who have no time to work.
Karl Kraus


More information about the melbourne-pug mailing list