123456789101112131415161718192021222324 |
- #! /usr/bin/python3
- #
- # This example shows some built in unit tests for functions, alone with
- # docstring examples.
- def square(x):
- """
- Returns x times itself.
- >>> square(2)
- 4
- >>> square(4)
- 16
- >>> square(333)
- 110889
- """
- return x*x
- if __name__ == "__main__":
- """
- This is how doctest would be used in a module.
- """
- import doctest
- doctest.testmod()
|