Running Doctest/Docutils

/ Published in: Python
Save to your folder(s)

This is going to run all doctests for all methods in a module. Doctests are a beautiful thing.
Note: doctest will only complain if a test fails. If you see on output then all your tests must have passed.

Copy this code and paste it in your HTML
  1. def add(x,y):
  2. """
  3. >>> add(5,6)
  4. 11
  5. """
  6. return x+y
  8. if __name__ == "__main__":
  9. import doctest
  10. doctest.testmod()


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.