[python-arrayfire] 198/250: Changing the test framework to be verbose on FAIL and exit with 1
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:48 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/master
in repository python-arrayfire.
commit 4156e48ca73e83907f55185653d2cdd49ec4faa6
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date: Tue Dec 22 18:58:23 2015 -0500
Changing the test framework to be verbose on FAIL and exit with 1
---
tests/simple/_util.py | 41 ++++++++++++++++++++++-------------------
tests/simple_tests.py | 2 +-
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/tests/simple/_util.py b/tests/simple/_util.py
index 7af1436..4b38e9c 100644
--- a/tests/simple/_util.py
+++ b/tests/simple/_util.py
@@ -6,36 +6,22 @@
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
-
import traceback
import logging
import arrayfire as af
-
-def display_func(verbose):
- if (verbose):
- return af.display
- else:
- def eval_func(foo):
- res = foo
- return eval_func
-
-def print_func(verbose):
- def print_func_impl(*args):
- if (verbose):
- print(args)
- else:
- res = [args]
- return print_func_impl
+import sys
class _simple_test_dict(dict):
def __init__(self):
self.print_str = "Simple %16s: %s"
+ self.failed = False
super(_simple_test_dict, self).__init__()
def run(self, name_list=None, verbose=False):
test_list = name_list if name_list is not None else self.keys()
for key in test_list:
+ self.print_log = ''
try:
test = self[key]
except:
@@ -47,8 +33,25 @@ class _simple_test_dict(dict):
print(self.print_str % (key, "PASSED"))
except Exception as e:
print(self.print_str % (key, "FAILED"))
- if (verbose):
- logging.error(traceback.format_exc())
+ self.failed = True
+ if (not verbose):
+ print(tests.print_log)
+ logging.error(traceback.format_exc())
+ if (self.failed):
+ sys.exit(1)
tests = _simple_test_dict()
+
+def print_func(verbose):
+ def print_func_impl(*args):
+ _print_log = ''
+ for arg in args:
+ _print_log += str(arg) + '\n'
+ if (verbose):
+ print(_print_log)
+ tests.print_log += _print_log
+ return print_func_impl
+
+def display_func(verbose):
+ return print_func(verbose)
diff --git a/tests/simple_tests.py b/tests/simple_tests.py
index 67fb8c9..370b162 100755
--- a/tests/simple_tests.py
+++ b/tests/simple_tests.py
@@ -16,7 +16,7 @@ if __name__ == "__main__":
verbose = False
if len(sys.argv) > 1:
- verbose = int(sys.argv[1]) != False
+ verbose = int(sys.argv[1])
test_list = None
if len(sys.argv) > 2:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-arrayfire.git
More information about the debian-science-commits
mailing list