Source

pymotw-ja / PyMOTW / doctest / doctest_testmod.py

#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
#
"""Simple example using doctest
"""
#end_pymotw_header

def my_function(a, b):
    """
    >>> my_function(2, 3)
    6
    >>> my_function('a', 3)
    'aaa'
    """
    return a * b
    
if __name__ == '__main__':
    import doctest
    doctest.testmod()