On Sun, Jan 3, 2010 at 4:48 PM, Lennart Regebro <regebro@gmail.com> wrote:
On Sun, Jan 3, 2010 at 22:08, Benji York <benji@zope.com> wrote:
Occasionally you want to show some code but hide the assertions about the effects of the code. You can do that by putting the tests in a reST comment after the code.
.. code-block:: python
a = Foo() b = a.bar()
.. make sure the above worked correctly
>>> b.baz 42
That doesn't work for code that will raise an exception.
Also, if you want to both run a command and make sure it's output is correct, then you need to do that twice.
In both of those cases normal doctest blocks seem appropriate. Calling foo with the wrong parameters raises an exception: >>> foo('wrong') Traceback (most recent call last): ... ValueError: bad parameters Calling the hello function prints a greeting. >>> hello() Hello world! -- Benji York