Sphinx Doctest: test the code without comparing the output.

Neil Cerutti neilc at norwich.edu
Mon Sep 23 09:42:13 EDT 2013


On 2013-09-22, Luca Cerone <luca.cerone at gmail.com> wrote:
> I understand your point, but now I am not writing unit tests to
> check the correctness of the code. I am only writing a tutorial
> and assuming that the code is correct. What I have to be sure
> is that the code in the tutorial can be executed correctly, and
> some commands print verbose output which can change.
>
> It is not enough to write >>> ignore = function(a,b,c) won't
> work because the function still prints messages on screen and
> this causes the failure of the test...

It won't be very good documenation any more but nothing stops you
from examining the result in the next doctest and making yourself
happy about it.

  >>> x = input("indeterminate:")
  >>> result = "'{}'".format(x))
  >>> result.startswith("'") and result.endswith("'")
  True

-- 
Neil Cerutti



More information about the Python-list mailing list