TestCenter Reference
TestSupport.Macros Namespace Reference

Adds GoogleTest like methods. More...

Functions

def ASSERT_TRUE
 Throw exception if given expression does not evaluate to true. More...
 
def EXPECT_TRUE
 Expect given expression to evaluate to true. More...
 
def ASSERT_FALSE
 Throw exception if given expression does not evaluate to false. More...
 
def EXPECT_FALSE
 Expect given expression to evaluate to false. More...
 
def ASSERT_EQ
 Throw exception if given values are not equal. More...
 
def EXPECT_EQ
 Expect given values to be equal. More...
 
def ASSERT_NE
 Throw exception if given values are equal. More...
 
def EXPECT_NE
 Expect given values to be not equal. More...
 
def ASSERT_GT
 Throw exception if first given value is less than or equal to the second. More...
 
def EXPECT_GT
 Expect first given value to be greater than the second. More...
 
def ASSERT_GE
 Throw exception if first given value is less than the second. More...
 
def EXPECT_GE
 Expect first given value to be greater than or equal to the second. More...
 
def ASSERT_LT
 Throw exception if first given value is not less than the second. More...
 
def EXPECT_LT
 Expect first given value to be less than the second. More...
 
def ASSERT_LE
 Throw exception if first given value is not less than or equal to the second. More...
 
def EXPECT_LE
 Expect first given value to be less than or equal to the second. More...
 
def ASSERT_FLOAT_EQ
 Throw exception if given values are not equal. More...
 
def EXPECT_FLOAT_EQ
 Expect given values to be equal. More...
 
def ASSERT_FLOAT_NE
 Throw exception if given values are equal. More...
 
def EXPECT_FLOAT_NE
 Expect given values to be not equal. More...
 
def ASSERT_FLOAT_GT
 Throw exception if first given value is not greater than the second. More...
 
def EXPECT_FLOAT_GT
 Expect first given value to be greater than the second. More...
 
def ASSERT_FLOAT_GE
 Throw exception if first given value is not greater than or equal to the second. More...
 
def EXPECT_FLOAT_GE
 Expect first given value to be greater than or equal to the second. More...
 
def ASSERT_FLOAT_LT
 Throw exception if first given value is not less than the second. More...
 
def EXPECT_FLOAT_LT
 Expect first given value to be less than the second. More...
 
def ASSERT_FLOAT_LE
 Throw exception if first given value is not less than or equal to the second. More...
 
def EXPECT_FLOAT_LE
 Expect first given value to be less than or equal to the second. More...
 
def EXPECT_EMPTY
 Expect given container to be empty. More...
 
def ASSERT_EMPTY
 Throw exception if given container is not empty. More...
 
def EXPECT_NOT_EMPTY
 Expect given container to be not empty. More...
 
def ASSERT_NOT_EMPTY
 Throw exception if given container is empty. More...
 
def EXPECT_SIZE
 Expect given container to have the given size. More...
 
def ASSERT_SIZE
 Throw exception if given container does not have the given size. More...
 
def EXPECT_PATH_EXISTS
 Expect the given path to exist. More...
 
def EXPECT_PATH_MISSING
 Expect the given path to be missing, i.e. More...
 
def ASSERT_PATH_EXISTS
 Throw exception if given path does not exists. More...
 
def ASSERT_PATH_MISSING
 Throw exception if given path is not missing, i.e. More...
 
def INFO (msg)
 Create an info message. More...
 
def WARNING (msg)
 Create a warning message. More...
 
def ERROR (msg)
 Create an error message. More...
 
def DEBUG_STOP ()
 Stops a test immediately for debugging purposes. More...
 

Detailed Description

Adds GoogleTest like methods.

GoogleTest has a set of macros to be used for testing. These methods are all written in upper case which helps identifying the relevant parts of a test function. This module add similar methods but note that the piping feature used in GoogleTest is not available in Python and therefore additional user information must be appended as method argument. This does not mean a restriction as piping is used as string concatenation in C++ is way harder than in Python.

By default, all macros log an info message if the assertion or expectation succeeds. This can be disabled for each call of a macro by passing logOnSuccess=False. It can also be disabled for a single test function by using the TestSupport.Base.MacrosShouldLogOnSuccessDecorator. And finally it can also be disabled by calling TestSupport.Base.setMacrosShouldLogOnSuccess in the setUpTestCase() method. It does not have to be reset, because the TestCenter enables it before each TestCase.

Function Documentation

def TestSupport.Macros.ASSERT_EMPTY (   a,
  msg = None,
  logOnSuccess = None 
)

Throw exception if given container is not empty.

Parameters
aContainer.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 413 of file Macros.py.

def TestSupport.Macros.ASSERT_EQ (   expected,
  actual,
  msg = None,
  logOnSuccess = None 
)

Throw exception if given values are not equal.

Parameters
expectedFirst value.
actualSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 107 of file Macros.py.

Referenced by TestSupport.UnitTestSupport.TestCaseWithSupportData.getFileInTestSupportDataDirectory().

def TestSupport.Macros.ASSERT_FALSE (   expr,
  msg = None,
  logOnSuccess = None 
)

Throw exception if given expression does not evaluate to false.

Parameters
exprExpression to be evaluated.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 83 of file Macros.py.

def TestSupport.Macros.ASSERT_FLOAT_EQ (   expected,
  actual,
  msg = None,
  epsilon = 0.0001,
  logOnSuccess = None 
)

Throw exception if given values are not equal.

Parameters
expectedFirst value.
actualSecond value.
msgMessage to be printed in case of failure.
epsilonEpsilon to use for equality check.
logOnSuccessPrint message in case of success.

Definition at line 253 of file Macros.py.

def TestSupport.Macros.ASSERT_FLOAT_GE (   a,
  b,
  msg = None,
  epsilon = 0.0001,
  logOnSuccess = None 
)

Throw exception if first given value is not greater than or equal to the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
epsilonEpsilon to use for equality check.
logOnSuccessPrint message in case of success.

Definition at line 329 of file Macros.py.

def TestSupport.Macros.ASSERT_FLOAT_GT (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Throw exception if first given value is not greater than the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 304 of file Macros.py.

def TestSupport.Macros.ASSERT_FLOAT_LE (   a,
  b,
  msg = None,
  epsilon = 0.0001,
  logOnSuccess = None 
)

Throw exception if first given value is not less than or equal to the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
epsilonEpsilon to use for equality check.
logOnSuccessPrint message in case of success.

Definition at line 379 of file Macros.py.

def TestSupport.Macros.ASSERT_FLOAT_LT (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Throw exception if first given value is not less than the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 354 of file Macros.py.

def TestSupport.Macros.ASSERT_FLOAT_NE (   expected,
  actual,
  msg = None,
  epsilon = 0.0001,
  logOnSuccess = None 
)

Throw exception if given values are equal.

Parameters
expectedFirst value.
actualSecond value.
msgMessage to be printed in case of failure.
epsilonEpsilon to use for equality check.
logOnSuccessPrint message in case of success.

Definition at line 279 of file Macros.py.

def TestSupport.Macros.ASSERT_GE (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Throw exception if first given value is less than the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 180 of file Macros.py.

def TestSupport.Macros.ASSERT_GT (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Throw exception if first given value is less than or equal to the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 156 of file Macros.py.

def TestSupport.Macros.ASSERT_LE (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Throw exception if first given value is not less than or equal to the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 228 of file Macros.py.

def TestSupport.Macros.ASSERT_LT (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Throw exception if first given value is not less than the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 204 of file Macros.py.

def TestSupport.Macros.ASSERT_NE (   expected,
  actual,
  msg = None,
  logOnSuccess = None 
)

Throw exception if given values are equal.

Parameters
expectedFirst value.
actualSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 131 of file Macros.py.

def TestSupport.Macros.ASSERT_NOT_EMPTY (   a,
  msg = None,
  logOnSuccess = None 
)

Throw exception if given container is empty.

Parameters
aContainer.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 433 of file Macros.py.

def TestSupport.Macros.ASSERT_PATH_EXISTS (   path,
  msg = None,
  logOnSuccess = None 
)

Throw exception if given path does not exists.

Parameters
pathThe path to check.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 485 of file Macros.py.

def TestSupport.Macros.ASSERT_PATH_MISSING (   path,
  msg = None,
  logOnSuccess = None 
)

Throw exception if given path is not missing, i.e.

if it exists.

Parameters
pathThe path to check.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 496 of file Macros.py.

def TestSupport.Macros.ASSERT_SIZE (   a,
  size,
  msg = None,
  logOnSuccess = None 
)

Throw exception if given container does not have the given size.

Parameters
aContainer.
sizeExpected size.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 455 of file Macros.py.

def TestSupport.Macros.ASSERT_TRUE (   expr,
  msg = None,
  logOnSuccess = None 
)

Throw exception if given expression does not evaluate to true.

Parameters
exprExpression to be evaluated.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 60 of file Macros.py.

Referenced by TestSupport.HelperFunctions.initModuleFromTemplate().

def TestSupport.Macros.DEBUG_STOP ( )

Stops a test immediately for debugging purposes.

Definition at line 525 of file Macros.py.

def TestSupport.Macros.ERROR (   msg)

Create an error message.

Definition at line 518 of file Macros.py.

Referenced by TestSupport.HelperFunctions.compareImages3D(), and TestSupport.HelperFunctions.compareImages6D().

def TestSupport.Macros.EXPECT_EMPTY (   a,
  msg = None,
  logOnSuccess = None 
)

Expect given container to be empty.

Parameters
aContainer.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 404 of file Macros.py.

def TestSupport.Macros.EXPECT_EQ (   expected,
  actual,
  msg = None,
  logOnSuccess = None 
)

Expect given values to be equal.

Parameters
expectedFirst value.
actualSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 120 of file Macros.py.

def TestSupport.Macros.EXPECT_FALSE (   expr,
  msg = None,
  logOnSuccess = None 
)

Expect given expression to evaluate to false.

Parameters
exprExpression that must be false.
msgMessage to be printed if expression true.
logOnSuccessPrint message in case of success.
Returns
True if expression evaluates to false.

Definition at line 96 of file Macros.py.

def TestSupport.Macros.EXPECT_FLOAT_EQ (   expected,
  actual,
  msg = None,
  epsilon = 0.0001,
  logOnSuccess = None 
)

Expect given values to be equal.

Parameters
expectedFirst value.
actualSecond value.
msgMessage to be printed in case of failure.
epsilonEpsilon to use for equality check.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 267 of file Macros.py.

def TestSupport.Macros.EXPECT_FLOAT_GE (   a,
  b,
  msg = None,
  epsilon = 0.0001,
  logOnSuccess = None 
)

Expect first given value to be greater than or equal to the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
epsilonEpsilon to use for equality check.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 343 of file Macros.py.

def TestSupport.Macros.EXPECT_FLOAT_GT (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Expect first given value to be greater than the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 317 of file Macros.py.

def TestSupport.Macros.EXPECT_FLOAT_LE (   a,
  b,
  msg = None,
  epsilon = 0.0001,
  logOnSuccess = None 
)

Expect first given value to be less than or equal to the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
epsilonEpsilon to use for equality check.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 393 of file Macros.py.

def TestSupport.Macros.EXPECT_FLOAT_LT (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Expect first given value to be less than the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 367 of file Macros.py.

def TestSupport.Macros.EXPECT_FLOAT_NE (   expected,
  actual,
  msg = None,
  epsilon = 0.0001,
  logOnSuccess = None 
)

Expect given values to be not equal.

Parameters
expectedFirst value.
actualSecond value.
msgMessage to be printed in case of failure.
epsilonEpsilon to use for equality check.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 293 of file Macros.py.

def TestSupport.Macros.EXPECT_GE (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Expect first given value to be greater than or equal to the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 193 of file Macros.py.

def TestSupport.Macros.EXPECT_GT (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Expect first given value to be greater than the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 169 of file Macros.py.

def TestSupport.Macros.EXPECT_LE (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Expect first given value to be less than or equal to the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 241 of file Macros.py.

def TestSupport.Macros.EXPECT_LT (   a,
  b,
  msg = None,
  logOnSuccess = None 
)

Expect first given value to be less than the second.

Parameters
aFirst value.
bSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 217 of file Macros.py.

def TestSupport.Macros.EXPECT_NE (   expected,
  actual,
  msg = None,
  logOnSuccess = None 
)

Expect given values to be not equal.

Parameters
expectedFirst value.
actualSecond value.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 144 of file Macros.py.

def TestSupport.Macros.EXPECT_NOT_EMPTY (   a,
  msg = None,
  logOnSuccess = None 
)

Expect given container to be not empty.

Parameters
aContainer.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 424 of file Macros.py.

def TestSupport.Macros.EXPECT_PATH_EXISTS (   path,
  msg = None,
  logOnSuccess = None 
)

Expect the given path to exist.

Parameters
pathThe path to check.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 465 of file Macros.py.

def TestSupport.Macros.EXPECT_PATH_MISSING (   path,
  msg = None,
  logOnSuccess = None 
)

Expect the given path to be missing, i.e.

it should not exist.

Parameters
pathThe path to check.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.

Definition at line 475 of file Macros.py.

def TestSupport.Macros.EXPECT_SIZE (   a,
  size,
  msg = None,
  logOnSuccess = None 
)

Expect given container to have the given size.

Parameters
aContainer.
sizeExpected size.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true in case of success.

Definition at line 445 of file Macros.py.

def TestSupport.Macros.EXPECT_TRUE (   expr,
  msg = None,
  logOnSuccess = None 
)

Expect given expression to evaluate to true.

Parameters
exprExpression to be evaluated.
msgMessage to be printed in case of failure.
logOnSuccessPrint message in case of success.
Returns
Returns true if expression evaluates to true.

Definition at line 72 of file Macros.py.

Referenced by TestSupport.RemoteRenderingEventReplay.EventReplay.imageReceived().

def TestSupport.Macros.INFO (   msg)

Create an info message.

Definition at line 504 of file Macros.py.

Referenced by TestSupport.HelperFunctions.compareImages3D(), and TestSupport.HelperFunctions.compareImages6D().

def TestSupport.Macros.WARNING (   msg)

Create a warning message.

Definition at line 511 of file Macros.py.