Back to index

salome-kernel  6.5.0
Classes | Functions
KERNEL_PY.kernel.pyunittester Namespace Reference

Classes

class  PyUnitTester
class  MyTestCase
class  MyTestCase2

Functions

def printfile
def execAndConvertExceptionToBoolean
def run
def functionRaisingAnException
def functionReturningFalse
def functionReturningTrue
def functionReturningNothing
def TEST_basic_usecase

Function Documentation

This can be used to just execute a test function that is
considered as OK simply if no exception is raised (can be test by
an assertTrue).

Definition at line 78 of file pyunittester.py.

00078 
00079 def execAndConvertExceptionToBoolean(function):
00080     """
00081     This can be used to just execute a test function that is
00082     considered as OK simply if no exception is raised (can be test by
00083     an assertTrue).
00084     """
00085     try:
00086         result = function()
00087         if result is None:
00088             return True
00089         return result
00090     except Exception, e:
00091         print e
00092         return False
00093 
00094 # Simple helper function for most cases where there is only one
# TestCase classe.

Here is the caller graph for this function:

Definition at line 124 of file pyunittester.py.

00124 
00125 def functionRaisingAnException():
00126     raise Exception("An error occurs")

Definition at line 127 of file pyunittester.py.

00127 
00128 def functionReturningFalse():
00129     return False

Definition at line 133 of file pyunittester.py.

00133 
00134 def functionReturningNothing():
00135     print "functionReturningNothing"

Definition at line 130 of file pyunittester.py.

00130 
00131 def functionReturningTrue():
00132     return True

Definition at line 23 of file pyunittester.py.

00023 
00024 def printfile(filename):
00025     stream = open(filename,'r')
00026     lines = stream.readlines()
00027     stream.close()
00028     for line in lines:
00029        if not termcolor.canDisplayColor(sys.stdout):
00030            msg = line.split('\n')[0]
00031        else:
00032             msg = termcolor.makeColoredMessage(line.split('\n')[0], termcolor.BLUE)
00033         print msg

Here is the caller graph for this function:

def KERNEL_PY.kernel.pyunittester.run (   testCaseClass)
Run the test suite provided by the specified TestCase class.

Definition at line 95 of file pyunittester.py.

00095 
00096 def run(testCaseClass):
00097     """
00098     Run the test suite provided by the specified TestCase class.
00099     """
00100     tester = PyUnitTester()
00101     tester.addTestCase(testCaseClass)
00102     tester.run()
00103 
00104 #
00105 # ==============================================================================
00106 # Simple use cases
00107 # ==============================================================================
#

Here is the caller graph for this function:

Definition at line 163 of file pyunittester.py.

00163 
00164 def TEST_basic_usecase():
00165     tester = PyUnitTester()
00166     # Note that the class keywords must be passed
00167     tester.addTestCase(MyTestCase)
00168     tester.addTestCase(MyTestCase2)
00169     tester.run()