TestCenter Reference
TestSupport.Macros Namespace Reference

Adds GoogleTest like methods. More...

Functions

 ASSERT_TRUE (expr, msg=None, logOnSuccess=None)
 Throw exception if given expression does not evaluate to true.
 
 EXPECT_TRUE (expr, msg=None, logOnSuccess=None)
 Expect given expression to evaluate to true.
 
 ASSERT_FALSE (expr, msg=None, logOnSuccess=None)
 Throw exception if given expression does not evaluate to false.
 
 EXPECT_FALSE (expr, msg=None, logOnSuccess=None)
 Expect given expression to evaluate to false.
 
 ASSERT_EQ (expected, actual, msg=None, logOnSuccess=None)
 Throw exception if given values are not equal.
 
 EXPECT_EQ (expected, actual, msg=None, logOnSuccess=None)
 Expect given values to be equal.
 
 ASSERT_NE (expected, actual, msg=None, logOnSuccess=None)
 Throw exception if given values are equal.
 
 EXPECT_NE (expected, actual, msg=None, logOnSuccess=None)
 Expect given values to be not equal.
 
 ASSERT_GT (a, b, msg=None, logOnSuccess=None)
 Throw exception if first given value is less than or equal to the second.
 
 EXPECT_GT (a, b, msg=None, logOnSuccess=None)
 Expect first given value to be greater than the second.
 
 ASSERT_GE (a, b, msg=None, logOnSuccess=None)
 Throw exception if first given value is less than the second.
 
 EXPECT_GE (a, b, msg=None, logOnSuccess=None)
 Expect first given value to be greater than or equal to the second.
 
 ASSERT_LT (a, b, msg=None, logOnSuccess=None)
 Throw exception if first given value is not less than the second.
 
 EXPECT_LT (a, b, msg=None, logOnSuccess=None)
 Expect first given value to be less than the second.
 
 ASSERT_LE (a, b, msg=None, logOnSuccess=None)
 Throw exception if first given value is not less than or equal to the second.
 
 EXPECT_LE (a, b, msg=None, logOnSuccess=None)
 Expect first given value to be less than or equal to the second.
 
 ASSERT_FLOAT_EQ (expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None)
 Throw exception if given values are not equal.
 
 EXPECT_FLOAT_EQ (expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None)
 Expect given values to be equal.
 
 ASSERT_FLOAT_NE (expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None)
 Throw exception if given values are equal.
 
 EXPECT_FLOAT_NE (expected, actual, msg=None, epsilon=0.0001, logOnSuccess=None)
 Expect given values to be not equal.
 
 ASSERT_FLOAT_GT (a, b, msg=None, logOnSuccess=None)
 Throw exception if first given value is not greater than the second.
 
 EXPECT_FLOAT_GT (a, b, msg=None, logOnSuccess=None)
 Expect first given value to be greater than the second.
 
 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.
 
 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.
 
 ASSERT_FLOAT_LT (a, b, msg=None, logOnSuccess=None)
 Throw exception if first given value is not less than the second.
 
 EXPECT_FLOAT_LT (a, b, msg=None, logOnSuccess=None)
 Expect first given value to be less than the second.
 
 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.
 
 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.
 
 EXPECT_EMPTY (a, msg=None, logOnSuccess=None)
 Expect given container to be empty.
 
 ASSERT_EMPTY (a, msg=None, logOnSuccess=None)
 Throw exception if given container is not empty.
 
 EXPECT_NOT_EMPTY (a, msg=None, logOnSuccess=None)
 Expect given container to be not empty.
 
 ASSERT_NOT_EMPTY (a, msg=None, logOnSuccess=None)
 Throw exception if given container is empty.
 
 EXPECT_SIZE (a, size, msg=None, logOnSuccess=None)
 Expect given container to have the given size.
 
 ASSERT_SIZE (a, size, msg=None, logOnSuccess=None)
 Throw exception if given container does not have the given size.
 
 EXPECT_PATH_EXISTS (path, msg=None, logOnSuccess=None)
 Expect the given path to exist.
 
 EXPECT_PATH_MISSING (path, msg=None, logOnSuccess=None)
 Expect the given path to be missing, i.e.
 
 ASSERT_PATH_EXISTS (path, msg=None, logOnSuccess=None)
 Throw exception if given path does not exists.
 
 ASSERT_PATH_MISSING (path, msg=None, logOnSuccess=None)
 Throw exception if given path is not missing, i.e.
 
 INFO (msg)
 Create an info message.
 
 WARNING (msg)
 Create a warning message.
 
 ERROR (msg)
 Create an error message.
 
 DEBUG_STOP ()
 Stops a test immediately for debugging purposes.
 

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

◆ ASSERT_EMPTY()

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 420 of file Macros.py.

◆ ASSERT_EQ()

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 114 of file Macros.py.

◆ ASSERT_FALSE()

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 90 of file Macros.py.

◆ ASSERT_FLOAT_EQ()

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 260 of file Macros.py.

◆ ASSERT_FLOAT_GE()

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 336 of file Macros.py.

◆ ASSERT_FLOAT_GT()

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 311 of file Macros.py.

◆ ASSERT_FLOAT_LE()

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 386 of file Macros.py.

◆ ASSERT_FLOAT_LT()

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 361 of file Macros.py.

◆ ASSERT_FLOAT_NE()

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 286 of file Macros.py.

◆ ASSERT_GE()

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 187 of file Macros.py.

◆ ASSERT_GT()

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 163 of file Macros.py.

◆ ASSERT_LE()

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 235 of file Macros.py.

◆ ASSERT_LT()

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 211 of file Macros.py.

◆ ASSERT_NE()

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 138 of file Macros.py.

◆ ASSERT_NOT_EMPTY()

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 440 of file Macros.py.

◆ ASSERT_PATH_EXISTS()

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 492 of file Macros.py.

◆ ASSERT_PATH_MISSING()

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 503 of file Macros.py.

◆ ASSERT_SIZE()

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 462 of file Macros.py.

◆ ASSERT_TRUE()

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 67 of file Macros.py.

◆ DEBUG_STOP()

TestSupport.Macros.DEBUG_STOP ( )

Stops a test immediately for debugging purposes.

Definition at line 532 of file Macros.py.

◆ ERROR()

TestSupport.Macros.ERROR ( msg)

Create an error message.

Definition at line 525 of file Macros.py.

◆ EXPECT_EMPTY()

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 411 of file Macros.py.

◆ EXPECT_EQ()

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 127 of file Macros.py.

◆ EXPECT_FALSE()

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 103 of file Macros.py.

◆ EXPECT_FLOAT_EQ()

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 274 of file Macros.py.

◆ EXPECT_FLOAT_GE()

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 350 of file Macros.py.

◆ EXPECT_FLOAT_GT()

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 324 of file Macros.py.

◆ EXPECT_FLOAT_LE()

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 400 of file Macros.py.

◆ EXPECT_FLOAT_LT()

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 374 of file Macros.py.

◆ EXPECT_FLOAT_NE()

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 300 of file Macros.py.

◆ EXPECT_GE()

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 200 of file Macros.py.

◆ EXPECT_GT()

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 176 of file Macros.py.

◆ EXPECT_LE()

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 248 of file Macros.py.

◆ EXPECT_LT()

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 224 of file Macros.py.

◆ EXPECT_NE()

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 151 of file Macros.py.

◆ EXPECT_NOT_EMPTY()

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 431 of file Macros.py.

◆ EXPECT_PATH_EXISTS()

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 472 of file Macros.py.

◆ EXPECT_PATH_MISSING()

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 482 of file Macros.py.

◆ EXPECT_SIZE()

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 452 of file Macros.py.

◆ EXPECT_TRUE()

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 79 of file Macros.py.

◆ INFO()

TestSupport.Macros.INFO ( msg)

Create an info message.

Definition at line 511 of file Macros.py.

◆ WARNING()

TestSupport.Macros.WARNING ( msg)

Create a warning message.

Definition at line 518 of file Macros.py.