→ doctest/

This commit is contained in:
neingeist 2020-01-10 14:39:12 +01:00
parent 130e7c57fd
commit 8b2473e5c8

31
doctest/doctest_test.py Normal file
View file

@ -0,0 +1,31 @@
#!/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()