[melbourne-pug] doctest: can you distinguish between a test & a variable setting?
Lars Yencken
lljy at csse.unimelb.edu.au
Thu Mar 26 23:40:55 CET 2009
Hi Mohamed,
2009/3/26 Mohamed Barwani <minnov at gmail.com>
> 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.
This is what you get when you run
doctest.testmod(verbose=True)
You can also instead use:
suite = doctest.DocTestSuite()
unittest.TextTestRunner().run(suite)
when you do this, you'll find only one test was registered by your example.
.
----------------------------------------------------------------------
Ran 1 test in 0.006s
OK
You're getting the extra stuff printed out just because you're asking
doctest to think out aloud with the verbose flag. Try using unittest to run
the tests instead.
Cheers,
Lars
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/melbourne-pug/attachments/20090327/ddadc6bb/attachment.htm>
More information about the melbourne-pug
mailing list