One consequence of the fact that the current buffer is imported before doctest is run is that any errors in the current buffer will prevent doctest from running successfully. In the example to the right, we have started defining a function slope(), but haven't added a body yet. If we run doctest-execute ("Control-c Control-c"), then doctest-mode will complain that it can't import the current buffer. |
def slope(dx, dy): def x_intercept(m, b): """ Return the x intercept of the line y=m*x+b. >>> x_intercept(3, 6) -2.0 >>> x_intercept(-4, 2) 0.5. """ return -float(b)/m ISO8---Emacs: mytest.py (Python[Doctest] MMM Font)----L9--All-- doctest-mode encountered an error while importing the current buffer: expected an indented block (doctest-oADBhB-globs.py, line 3) ISO8---Emacs: *doctest-output* (Doctest Results Font)----L1--All- Doctest failed -- exited abnormally with code 1 |