Skip to content

Instantly share code, notes, and snippets.

@alexandre
Created March 13, 2015 18:12
Show Gist options
  • Select an option

  • Save alexandre/04e1a3e03ee56b3cc2ad to your computer and use it in GitHub Desktop.

Select an option

Save alexandre/04e1a3e03ee56b3cc2ad to your computer and use it in GitHub Desktop.
An example of python doctest
def factorial(number):
"""Return the factorial of the parameter 'number'
:number: an int object.
:returns: an int object.
>>> factorial(5)
120
"""
return ((number <= 1 and 1) or number * factorial(number - 1))
@alexandre

Copy link
Copy Markdown
Author

To test it, just run:

$ python -m doctest doctest_example.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment