examples/functions/fibonacci_doctest.py
from __future__ import print_function

def fib(n):
    '''
    >>> fib(3)
    2
    >>> fib(10)
    55
    >>> [fib(n) for n in range(11)]
    [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

    >>> fib(11)
    89
    '''
    values = [0, 1]

    if n == 11:
        return 'bug'

    while( n > len(values) -1 ):
        values.append(values[-1] + values[-2])
    return values[n]

if __name__ == "__main__":
    import doctest
    doctest.testmod()
**********************************************************************
File ".../examples/functions/fibonacci_doctest.py", line 12, in __main__.fib
Failed example:
    fib(11)
Expected:
    89
Got:
    'bug'
**********************************************************************
1 items had failures:
   1 of   4 in __main__.fib
***Test Failed*** 1 failures.

doctest