Doctests#

[1]:
import doctest

def add(a, b):
    '''
    This is a test:
    >>> add(7,6)
    13
    '''
    return a + b

doctest.testmod(verbose=True)
Trying:
    add(7,6)
Expecting:
    13
ok
1 items had no tests:
    __main__
1 items passed all tests:
   1 tests in __main__.add
1 tests in 2 items.
1 passed and 0 failed.
Test passed.
[1]:
TestResults(failed=0, attempted=1)