[Zope3-dev] help with doctests
Marius Gedminas
mgedmin at b4net.lt
Fri Jul 20 04:15:42 EDT 2007
On Fri, Jul 20, 2007 at 09:48:52AM +0200, Adam Groszer wrote:
> Hello,
>
> In z.a.apidoc.browser.README.txt I can write
> """
> >>> browser.open('http://localhost/++apidoc++/non-existent/')
> Traceback (most recent call last):
> ...
> httperror_seek_wrapper: HTTP Error 404: Not Found
> """
> (test passes)
>
> but I can't write
> """
> >>> browser.open('http://localhost/++apidoc++/non-existent/')
> Traceback (most recent call last):
> ...
> ...HTTP Error 404: Not Found
> """
> it throws:
> """
> Failed example:
> browser.open('http://localhost/++apidoc++/non-existent/')
> Exception raised:
> Traceback (most recent call last):
> File "U:\zope\svn_zope34\src\zope\testing\doctest.py", line 1348, in __run
>
> compileflags, 1) in test.globs
> File "<doctest README.txt[3]>", line 1, in ?
> browser.open('http://localhost/++apidoc++/non-existent/')
> File "U:\zope\svn_zope34\src\zope\testbrowser\browser.py", line 224, in open
> self.mech_browser.open(url, data)
> File "U:\zope\svn_zope34\src\mechanize\_mechanize.py", line 203, in open
> return self._mech_open(url, data)
> File "U:\zope\svn_zope34\src\mechanize\_mechanize.py", line 254, in _mech_open
> raise response
> httperror_seek_wrapper: HTTP Error 404: Not Found
> """
>
> what do I miss?
doctests have special rules for exceptions that are different from the
rules of normal output matching.
If a statement raises an exception, the output part must be of the form
Traceback (most recent call last):
...
<exception type>: <exception value>
You can use ellipsis in the exception value part, IIRC.
Marius Gedminas
--
HOST SYSTEM NOT RESPONDING, PROBABLY DOWN. DO YOU WANT TO WAIT? (Y/N)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20070720/ee77e91e/attachment.bin
More information about the Zope3-dev
mailing list