[Numpy-discussion] Code samples in docstrings mistaken as doctests

Stéfan van der Walt stefan@sun.ac...
Mon Jun 23 14:21:51 CDT 2008

2008/6/23 Fernando Perez <fperez.net@gmail.com>:
> On Mon, Jun 23, 2008 at 11:17 AM, Alan McIntyre <alan.mcintyre@gmail.com> wrote:
>> On Mon, Jun 23, 2008 at 2:02 PM, Fernando Perez <fperez.net@gmail.com> wrote:
>>> There's also the option of marking them so doctest skips them via
>>> #doctest: +SKIP
>>> http://docs.python.org/lib/doctest-options.html
>> For short examples, that seems like a good option, but it seems like
>> you have to have that comment on every line that you want skipped.
>> There are some long examples (like the one in
>> lib/function_base.py:bartlett) that (to me) would look pretty ugly
>> having that comment tacked on to every line.
> Ugh.  Definitely too ugly if it has to go in every line.  From reading
> the docs I interpreted it as affecting the whole example, which would
> be far more sensible...
>> Either way is fine with me in the end, though, so long as it doesn't
>> produce test failures. :)
> Yes, but we also want to make these really easy for users to cleanly
> paste in with minimal effort.  I wonder if a decorator could be
> applied to those functions so that nose would then skip the doctests:
> @skip_doctest
> def foo()....

Another alternative is to replace +SKIP with something like +IGNORE.
That way, the statement is still executed, we just don't care about
its outcome.  If we skip the line entirely, it often affects the rest
of the tests later on.



for an example implementation.


More information about the Numpy-discussion mailing list