Sphinx Doctest: test the code without comparing the output.

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Sep 21 11:48:34 EDT 2013


On Sat, 21 Sep 2013 05:44:09 -0700, Luca Cerone wrote:

> If you use a SKIP
> directive on code that contains a typo, or maybe you changed the name of
> a keyword to make it more meaningful and forgot to update your
> docstring, then the error won't be caught.

And if you ignore the output, the error won't be caught either. What's 
the difference?


>>> 1 + 1  #doctest:+IGNORE_OUTPUT  (not a real directive)
1000

Since doctest is ignoring the output, it won't catch the failure. Even if 
your code raises an exception, if you ignore the output, you'll never see 
the exception because it is ignored.

So you simply can't do what you want. You can't both ignore the output of 
a doctest and have doctest report if the test fails.


-- 
Steven



More information about the Python-list mailing list