Re: patterns for using sphinx with the Zope Toolkit?

Benji York <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
On Sun, Jan 3, 2010 at 4:48 PM, Lennart Regebro <[email protected]> wrote:
> On Sun, Jan 3, 2010 at 22:08, Benji York <[email protected]> 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
_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.