Back to index

salome-kernel  6.5.0
Functions | Variables
KERNEL_PY.kernel.unittester Namespace Reference

Functions

def run
def tryfunction
def TEST_myTestIsOk
def TEST_myTestIsNotOk

Variables

string __author__ = "gboulant"
string __date__ = "$1 avr. 2010 09:45:21$"

Function Documentation

def KERNEL_PY.kernel.unittester.run (   modulePath,
  functionName 
)
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)

Definition at line 25 of file unittester.py.

00025 
00026 def run(modulePath, functionName):
00027     """
00028     This function should be used for very basic unit tests and only for a
00029     rapid development. A better way should be the pyunit framework.
00030     The function functionName is supposed here to return a boolean value
00031     indicating if the test is OK (True) or NOT OK (False)
00032     """
00033     moduleName = modulePath.replace('/','.') 
00034     __import__ (moduleName)
00035     module=sys.modules[moduleName]
00036     func = getattr(module,functionName)
00037     tabsize = 70-len(moduleName)-len(functionName)
00038     print "[TEST] %s.%s %s test in progress" % (moduleName, functionName,"."*tabsize) 
00039     ok = func()
00040     if ( ok ):
00041         print "[TEST] %s.%s %s OK" % (moduleName, functionName,"."*tabsize)
00042     else:
00043         print "[TEST] %s.%s %s NOT OK" % (moduleName, functionName,"."*tabsize)

Here is the caller graph for this function:

Definition at line 67 of file unittester.py.

00067 
00068 def TEST_myTestIsNotOk():
00069     return False

Here is the call graph for this function:

Definition at line 64 of file unittester.py.

00064 
00065 def TEST_myTestIsOk():
00066     return True

def KERNEL_PY.kernel.unittester.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
process).

Definition at line 44 of file unittester.py.

00044 
00045 def tryfunction(function,*argv):
00046     """
00047     This function is for debug only. It executes the specified function with the
00048     specified arguments in a try/except bloc so that to display the exception in
00049     the case where an exception is raised (usefull to debug server side of a CORBA
00050     process).
00051     """
00052     print "[TEST] trying the function %s" % function
00053     try:
00054         return function(*argv)
00055     except Exception, e:
00056         print e
00057         raise e
00058 
00059 
00060 #
00061 # ==============================================================================
00062 # Simple use cases
00063 # ==============================================================================
#

Variable Documentation

Definition at line 20 of file unittester.py.

string KERNEL_PY.kernel.unittester.__date__ = "$1 avr. 2010 09:45:21$"

Definition at line 21 of file unittester.py.