From 9dbefe0ff113c632be974a5d4a36a050d4adf599 Mon Sep 17 00:00:00 2001 From: Tim Savannah Date: Wed, 4 Jan 2017 17:03:09 -0500 Subject: [PATCH] Add simple test program, 'testit' --- MANIFEST.in | 1 + testit.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 testit.py diff --git a/MANIFEST.in b/MANIFEST.in index 4a8d1d5..db642d5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/testit.py b/testit.py new file mode 100755 index 0000000..297f198 --- /dev/null +++ b/testit.py @@ -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