Add simple test program, 'testit'

This commit is contained in:
Tim Savannah 2017-01-04 17:03:09 -05:00
parent 675d68254d
commit 9dbefe0ff1
2 changed files with 23 additions and 0 deletions

View File

@ -4,5 +4,6 @@ include README.md
include README.rst
include MANIFEST.in
include ChangeLog
include testit.py
recursive-include func_timeout *.py
recursive-include doc *.html

22
testit.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
from func_timeout import func_timeout, FunctionTimedOut
import time
import sys
def doit(howmany):
time.sleep(2)
return 17 + howmany
if __name__ == '__main__':
print ( "Should get return value of 23:" )
print ( "\tGot Return: %s\n" %(str(func_timeout(4, doit, args=(6,))),) )
print ( "\nShould time out (exception):" )
try:
print ("\tGot Return: %s\n" %(str(func_timeout(1, doit, kwargs={'howmany' : 16})),))
except FunctionTimedOut as e:
sys.stderr.write('\tGot Exception: %s\n' %(str(e),))
pass