Salome HOME
Merge changes from 'master' branch.
[modules/kernel.git] / src / KERNEL_PY / kernel / unittester.py
index 25b27cb834924f136504730d59498b444d80ab70..9abb4fa4c99b351c64ee4b2dd394b0686218b152 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: iso-8859-1 -*-
-# Copyright (C) 2010-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2010-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 #
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
+
+## \defgroup unittester unittester
+#  \{ 
+#  \details Run very basic unit tests
+#  \}
+
 __author__="gboulant"
 __date__ ="$1 avr. 2010 09:45:21$"
 
 import sys
 
+## This function should be used for very basic unit tests and only for a
+#  rapid development. %A better way should be the pyunit framework.
+#  The function functionName is supposed here to return a boolean value
+#  indicating if the test is OK (True) or NOT OK (False)
+#  \ingroup unittester
 def run(modulePath, functionName):
     """
     This function should be used for very basic unit tests and only for a
@@ -34,25 +45,30 @@ def run(modulePath, functionName):
     module=sys.modules[moduleName]
     func = getattr(module,functionName)
     tabsize = 70-len(moduleName)-len(functionName)
-    print "[TEST] %s.%s %s test in progress" % (moduleName, functionName,"."*tabsize
+    print("[TEST] %s.%s %s test in progress" % (moduleName, functionName,"."*tabsize)
     ok = func()
     if ( ok ):
-        print "[TEST] %s.%s %s OK" % (moduleName, functionName,"."*tabsize)
+        print("[TEST] %s.%s %s OK" % (moduleName, functionName,"."*tabsize))
     else:
-        print "[TEST] %s.%s %s NOT OK" % (moduleName, functionName,"."*tabsize)
+        print("[TEST] %s.%s %s NOT OK" % (moduleName, functionName,"."*tabsize))
 
+## This function is for debug only. It executes the specified function with the
+#  specified arguments in a try/except block so as to display the exception in
+#  the case where an exception is raised (useful to debug server side of a CORBA
+#  process).
+#  \ingroup unittester
 def tryfunction(function,*argv):
     """
     This function is for debug only. It executes the specified function with the
-    specified arguments in a try/except bloc so that to display the exception in
-    the case where an exception is raised (usefull to debug server side of a CORBA
+    specified arguments in a try/except block so as to display the exception in
+    the case where an exception is raised (useful to debug server side of a CORBA
     process).
     """
-    print "[TEST] trying the function %s" % function
+    print("[TEST] trying the function %s" % function)
     try:
         return function(*argv)
-    except Exception, e:
-        print e
+    except Exception as e:
+        print(e)
         raise e