From af0ca7262b04ae406edbbbfeee0900d0df07834c Mon Sep 17 00:00:00 2001 From: neingeist Date: Sat, 16 Aug 2014 22:31:39 +0200 Subject: [PATCH] add a simple doctest example --- doctest_test.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 doctest_test.py diff --git a/doctest_test.py b/doctest_test.py new file mode 100644 index 0000000..3ebea9c --- /dev/null +++ b/doctest_test.py @@ -0,0 +1,29 @@ +#!/usr/bin/python + +def foo(n): + """Returns n times foo, and a period. + + Just some random doctest test. + + Example: + + >>> foo(1) + 'foo.' + + >>> foo(5) + 'foo foo foo foo foo.' + + >>> foo(0) + '' + """ + if n >= 1: + return "foo " * (n-1) + "foo." + else: + return "" + +def _test(): + import doctest + doctest.testmod() + +if __name__ == "__main__": + _test()