TestCenter Reference
TestSupport.Base Namespace Reference

Basic support functions. More...

Classes

class  HtmlDiff
 
class  MacrosShouldLogOnSuccessDecorator
 Decorator to globally enable or disable if the ASSERT_*/EXPECT_* macros log an info message on success. More...
 

Functions

 clearEncodingCache ()
 
 getSourceFileEncoding (filename)
 
 decodeSourceCodeLine (filename, line)
 
 getPackageList ()
 Returns the list of available packages.
 
 getTestCaseContext ()
 Get the context of the test.
 
 getModuleName ()
 Return the name of the currently tested module.
 
 getTestFunctionName ()
 Returns the name of the current test function.
 
 setMacrosShouldLogOnSuccess (logOnSuccess)
 Globally enables or disables if the ASSERT_*/EXPECT_* macros log an info message on success.
 
 shouldLogOnSuccess (logOnSuccess=None)
 
 LoggingDecorator (func)
 Internal decorator used for creating messages in compare methods.
 
 escapedUnicode (value)
 Returns a unicode representation of value.
 
 compareEqual (a, b, comment="", logOnSuccess=None)
 Compare the two given values for equality.
 
 compareNotEqual (a, b, comment="", logOnSuccess=None)
 Compare the two given values for inequality.
 
 compareLessThan (a, b, comment="", logOnSuccess=None)
 Compare the two given values if the first one is less than the second.
 
 compareGreaterThan (a, b, comment="", logOnSuccess=None)
 Compare the two given values if the first one is greater than the second.
 
 compareGreaterThanOrEqual (a, b, comment="", logOnSuccess=None)
 Compare the two given values if the first one is greater than or equal to the second.
 
 compareLessThanOrEqual (a, b, comment="", logOnSuccess=None)
 Compare the two given values if the first one is less than or equal to the second.
 
 compareFloatEqual (a, b, comment="", epsilon=0.0001, logOnSuccess=None)
 Compare the two given float values if they are epsilon-equal.
 
 compareFloatNotEqual (a, b, comment="", epsilon=0.0001, logOnSuccess=None)
 Compare the two given float values if they are epsilon-unequal.
 
 compareFloatLessThan (a, b, comment="", logOnSuccess=None)
 Compare the two given float values if the first is less than the second.
 
 compareFloatGreaterThan (a, b, comment="", logOnSuccess=None)
 Compare the two given float values if the first is greater than the second.
 
 compareFloatLessThanOrEqual (a, b, comment="", epsilon=0.0001, logOnSuccess=None)
 Compare the two given float values if the first is less than or equal to the second.
 
 compareFloatGreaterThanOrEqual (a, b, comment="", epsilon=0.0001, logOnSuccess=None)
 Compare the two given float values if the first is greater than or equal to the second.
 
 verifyTrue (expr, comment="", logOnSuccess=None, msg=None)
 If the given expression evaluates to False, an error is logged.
 
 verifyFalse (expr, comment="", logOnSuccess=None, msg=None)
 If the given expression evaluates to True, an error is logged.
 
 expectError (function, args=(), kwargs=None, errorRegExp=None, preventReplacingMessageSeverity=False, *kargs=None)
 Call the given function with the given parameters and expect an error.
 
 expectWarning (function, args=(), kwargs=None, warningRegExp=None, *kargs=None)
 Call the given function with the given parameters and expect a warning.
 
 expectWarningAndError (function, args=(), kwargs=None, errorRegExp=None, warningRegExp=None, *kargs=None)
 Call the given function with the given parameters and expect both a warning and an error.
 
 ignoreError (function, args=(), kwargs=None, errorRegExp=None, resultInfoDict=None, *kargs=None)
 Call the given function with the given parameters and ignores potential errors.
 
 ignoreWarning (function, args=(), kwargs=None, warningRegExp=None, resultInfoDict=None, *kargs=None)
 Call the given function with the given parameters and ignores potential warnings.
 
 ignoreWarningAndError (function, args=(), kwargs=None, errorRegExp=None, warningRegExp=None, resultInfoDict=None, *kargs=None)
 Call the given function with the given parameters and ignore both a warning and an error.
 
 expectInfo (function, args=(), kwargs=None, infoRegExp=None, allowUnexpectedMessages=True, *kargs=None)
 Call the given function with the given parameters and expect an info message.
 
 hasNoWarning (warningRegExp=None)
 Expect that the expression in the context block issues no warning that matches warningRegExp.
 
 hasWarning (warningRegExp=None)
 Expect that the expression in the context block logs a warning that matches warningRegExp.
 
 hasError (errorRegExp=None)
 Expect that the expression in the context logs an error that matches errorRegExp.
 
 hasWarningAndError (errorRegExp=None, warningRegExp=None)
 Expect that the expression in the context logs errors and warnings.
 
 hasInfo (infoRegExp=None, allowUnexpectedMessages=True)
 Expect that the expression in the context logs an info entry that matches infoRegExp.
 
 getResultDirectory ()
 Getter for the directory used to save results.
 
 getDataDirectory ()
 Method to return path to the data files.
 
 getFileInDataDirectory (filename)
 Returns the absolute filename of a file in the data directory using getDataDirectory().
 
 existsFileInDataDirectory (filename)
 Checks if the given file exists in the data directory.
 
 getExternalDataDirectory (name, subDirectory=None)
 Method to return path to the external data directory.
 
 pushChangeSet ()
 Push a new ChangeSet to the stack.
 
 popChangeSet ()
 Pop the last ChangeSet from the stack.
 
 getHash (filename, hash="SHA1", encoder="Hex")
 Compute a hash for the content of the given file.
 
 createExtraTestCaseResult (testCaseName, package, author, duration, maintainer=None, file=None, line=None, comment=None, showTestFunctionSortingLiterals=False)
 Creates an ExtraTestCaseResult object.
 
 addExtraTestCaseResult (extraTestCaseResult)
 Adds an ExtraTestCaseResult object.
 
 pushEnvironment ()
 Pushes the current environment dictionary on a stack, so that modifications can be applied and be popped again later.
 
 popEnvironment ()
 Pops the last pushed environment dictionary from a stack and makes it the current one.
 
 pushEnvironmentDecorator (func)
 
 EnableHighPrecisionLoggingTimeStampsDecorator (func)
 
 createHtmlDiff (fromLines, toLines, showOnlyContextOfDiff=False, numberOfContextLines=10)
 
 disableTestFunctionIf (condition)
 
 hardwareSupportsOffscreenRendering ()
 
 runProcess (command, wait=True, expectSuccess=True, expectFailure=False, verbose=True, env=None)
 
 verifyProcessResult (command, shortCommand, returncode, stdout, stderr, expectSuccess=True, expectFailure=False, verbose=True)
 
 runPythonScript (script, arguments, wait=True, expectSuccess=True, expectFailure=False, verbose=True, env=None)
 

Variables

 gEncodingRegExp = re.compile("^[ \t\v]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)")
 
dict gEncodingCache = {}
 

Detailed Description

Basic support functions.

Function Documentation

◆ addExtraTestCaseResult()

TestSupport.Base.addExtraTestCaseResult (   extraTestCaseResult)

Adds an ExtraTestCaseResult object.

See createExtraTestCaseResult().

Parameters
extraTestCaseResultA ExtraTestCaseResult object.

Definition at line 976 of file Base.py.

References TestSupport.Base.addExtraTestCaseResult().

Referenced by TestSupport.Base.addExtraTestCaseResult().

◆ clearEncodingCache()

TestSupport.Base.clearEncodingCache ( )

Definition at line 47 of file Base.py.

Referenced by TestCenterAdvanced.Slave.Slave.unloadTestCase().

◆ compareEqual()

TestSupport.Base.compareEqual (   a,
  b,
  comment = "",
  logOnSuccess = None 
)

Compare the two given values for equality.

If the two values are unequal an error is logged.

Parameters
aThe first value.
bThe second value.
commentOptional comment shown if comparison fails.
logOnSuccessPrint message in case of success.
Returns
True if values are equal.

Definition at line 232 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareFloatEqual()

TestSupport.Base.compareFloatEqual (   a,
  b,
  comment = "",
  epsilon = 0.0001,
  logOnSuccess = None 
)

Compare the two given float values if they are epsilon-equal.

Parameters
aThe first value.
bThe second value.
commentComment shown if comparison fails.
epsilonEpsilon used for float comparison.
logOnSuccesPrint message in case of success.
Returns
True if values are equal.

Definition at line 362 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareFloatGreaterThan()

TestSupport.Base.compareFloatGreaterThan (   a,
  b,
  comment = "",
  logOnSuccess = None 
)

Compare the two given float values if the first is greater than the second.

Parameters
aThe first value.
bThe second value.
commentComment shown if comparison fails.
logOnSuccesPrint message in case of success.
Returns
True if first value is greater than the second.

Definition at line 411 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareFloatGreaterThanOrEqual()

TestSupport.Base.compareFloatGreaterThanOrEqual (   a,
  b,
  comment = "",
  epsilon = 0.0001,
  logOnSuccess = None 
)

Compare the two given float values if the first is greater than or equal to the second.

Parameters
aThe first value.
bThe second value.
commentComment shown if comparison fails.
epsilonEpsilon used for float comparison.
logOnSuccesPrint message in case of success.
Returns
True if first value is greater than or equal to the second.

Definition at line 447 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareFloatLessThan()

TestSupport.Base.compareFloatLessThan (   a,
  b,
  comment = "",
  logOnSuccess = None 
)

Compare the two given float values if the first is less than the second.

Parameters
aThe first value.
bThe second value.
commentComment shown if comparison fails.
logOnSuccesPrint message in case of success.
Returns
True if first value is less than the second.

Definition at line 395 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareFloatLessThanOrEqual()

TestSupport.Base.compareFloatLessThanOrEqual (   a,
  b,
  comment = "",
  epsilon = 0.0001,
  logOnSuccess = None 
)

Compare the two given float values if the first is less than or equal to the second.

Parameters
aThe first value.
bThe second value.
commentComment shown if comparison fails.
epsilonEpsilon used for float comparison.
logOnSuccesPrint message in case of success.
Returns
True if first value is less than or equal to the second.

Definition at line 429 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareFloatNotEqual()

TestSupport.Base.compareFloatNotEqual (   a,
  b,
  comment = "",
  epsilon = 0.0001,
  logOnSuccess = None 
)

Compare the two given float values if they are epsilon-unequal.

Parameters
aThe first value.
bThe second value.
commentComment shown if comparison fails.
epsilonEpsilon used for float comparison.
logOnSuccesPrint message in case of success.
Returns
True if values are unequal.

Definition at line 379 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareGreaterThan()

TestSupport.Base.compareGreaterThan (   a,
  b,
  comment = "",
  logOnSuccess = None 
)

Compare the two given values if the first one is greater than the second.

Parameters
aThe first value.
bThe second value.
commentOptional comment shown if comparison fails.
logOnSuccessPrint message in case of success.
Returns
True if the first value is greater than the second.

Definition at line 299 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareGreaterThanOrEqual()

TestSupport.Base.compareGreaterThanOrEqual (   a,
  b,
  comment = "",
  logOnSuccess = None 
)

Compare the two given values if the first one is greater than or equal to the second.

Parameters
aThe first value.
bThe second value.
commentOptional comment shown if comparison fails.
logOnSuccessPrint message in case of success.
Returns
True if the first value greater than or equal to the second.

Definition at line 320 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareLessThan()

TestSupport.Base.compareLessThan (   a,
  b,
  comment = "",
  logOnSuccess = None 
)

Compare the two given values if the first one is less than the second.

Parameters
aThe first value.
bThe second value.
commentOptional comment shown if comparison fails.
logOnSuccessPrint message in case of success.
Returns
True if the first value is less than the second.

Definition at line 279 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareLessThanOrEqual()

TestSupport.Base.compareLessThanOrEqual (   a,
  b,
  comment = "",
  logOnSuccess = None 
)

Compare the two given values if the first one is less than or equal to the second.

Parameters
aThe first value.
bThe second value.
commentOptional comment shown if comparison fails.
logOnSuccessPrint message in case of success.
Returns
True if the first value less than or equal to the second.

Definition at line 341 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ compareNotEqual()

TestSupport.Base.compareNotEqual (   a,
  b,
  comment = "",
  logOnSuccess = None 
)

Compare the two given values for inequality.

If the two values are equal an error is logged.

Parameters
aThe first value.
bThe second value.
commentOptional comment shown if comparison fails.
logOnSuccessPrint message in case of success.
Returns
True if the values are unequal.

Definition at line 256 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ createExtraTestCaseResult()

TestSupport.Base.createExtraTestCaseResult (   testCaseName,
  package,
  author,
  duration,
  maintainer = None,
  file = None,
  line = None,
  comment = None,
  showTestFunctionSortingLiterals = False 
)

Creates an ExtraTestCaseResult object.

The extra test case results enable test cases to provide additional results as a test case. For example, this is used for web tests, where the web application generates an xml report.

Parameters
testCaseNameThe name of the test case.
packageThe MeVisLab package of the test case.
authorThe author of the test case.
maintainerThe current maintainer of the test case.
Returns
The ExtraTestCaseResult object.

Definition at line 953 of file Base.py.

◆ createHtmlDiff()

TestSupport.Base.createHtmlDiff (   fromLines,
  toLines,
  showOnlyContextOfDiff = False,
  numberOfContextLines = 10 
)

Definition at line 1092 of file Base.py.

◆ decodeSourceCodeLine()

TestSupport.Base.decodeSourceCodeLine (   filename,
  line 
)

Definition at line 75 of file Base.py.

References TestSupport.Base.getSourceFileEncoding().

Referenced by TestSupport.Base.LoggingDecorator().

◆ disableTestFunctionIf()

TestSupport.Base.disableTestFunctionIf (   condition)

Definition at line 1101 of file Base.py.

◆ EnableHighPrecisionLoggingTimeStampsDecorator()

TestSupport.Base.EnableHighPrecisionLoggingTimeStampsDecorator (   func)

Definition at line 1024 of file Base.py.

◆ escapedUnicode()

TestSupport.Base.escapedUnicode (   value)

Returns a unicode representation of value.

If value is of type bytes then non-ASCII characters are escaped and a representation of the string is returned. For example, the 8-bit literal b'\x01' becomes 'u"\x01"'.

Definition at line 212 of file Base.py.

◆ existsFileInDataDirectory()

TestSupport.Base.existsFileInDataDirectory (   filename)

Checks if the given file exists in the data directory.

Returns
True if the file exists in the data directory, False otherwise.

Definition at line 836 of file Base.py.

References TestSupport.Base.getFileInDataDirectory().

◆ expectError()

TestSupport.Base.expectError (   function,
  args = (),
  kwargs = None,
  errorRegExp = None,
  preventReplacingMessageSeverity = False,
kargs = None 
)

Call the given function with the given parameters and expect an error.

Please note that nesting the expect{Warning, Error} methods will lead to invalid line numbers in the reports!

Parameters
functionThe function to be called.
argsList of parameters for the function.
kwargsDictionary of named parameters for the function.
errorRegExpOptional RegexObject to control which errors are handled. (Strings will be assumed to be regular expressions and compiled automatically.)
preventReplacingMessageSeverityIf True, then the error state of the diagnosis console is not cleared. The test case must call MLAB.priv().clearLogState() itself in order to prevent it from failing. Default is False.
Returns
Return value of the called function.

Definition at line 507 of file Base.py.

◆ expectInfo()

TestSupport.Base.expectInfo (   function,
  args = (),
  kwargs = None,
  infoRegExp = None,
  allowUnexpectedMessages = True,
kargs = None 
)

Call the given function with the given parameters and expect an info message.

Please note that nesting the expect{Warning, Error, Info} methods will lead to invalid line numbers in the reports!

Parameters
functionThe function to be called.
argsList of parameters for the function.
kwargsDictionary of named parameters for the function.
infoRegExpOptional RegexObject to control which info messages are expected.
allowUnexpectedMessagesOptional flag to specify if unexpected messages are allowed.
Returns
Return value of the called function.

Definition at line 687 of file Base.py.

◆ expectWarning()

TestSupport.Base.expectWarning (   function,
  args = (),
  kwargs = None,
  warningRegExp = None,
kargs = None 
)

Call the given function with the given parameters and expect a warning.

Please note that nesting the expect{Warning, Error, Info} methods will lead to invalid line numbers in the reports!

Parameters
functionThe function to be called.
argsList of parameters for the function.
kwargsDictionary of named parameters for the function.
warningRegExpOptional RegexObject to control which warnings are handled. (Strings will be assumed to be regular expressions and compiled automatically.)
Returns
Return value of the called function.

Definition at line 533 of file Base.py.

◆ expectWarningAndError()

TestSupport.Base.expectWarningAndError (   function,
  args = (),
  kwargs = None,
  errorRegExp = None,
  warningRegExp = None,
kargs = None 
)

Call the given function with the given parameters and expect both a warning and an error.

Please note that nesting the expect{Warning, Error, Info} methods will lead to invalid line numbers in the reports!

Parameters
functionThe function to be called.
argsList of parameters for the function.
kwargsDictionary of named parameters for the function.
errorRegExpOptional RegexObject to control which errors are handled.
warningRegExpOptional RegexObject to control which warnings are handled.
Returns
Return value of the called function.

Definition at line 559 of file Base.py.

◆ getDataDirectory()

TestSupport.Base.getDataDirectory ( )

Method to return path to the data files.

Sometimes data is required for test case that should not reside inside the repository. This is where the dataDirectory option in the test case definition comes into play. This is the value that can be changed using this tag. The default is /Data.

Returns
The path to the directory where required data lives.

Definition at line 816 of file Base.py.

Referenced by TestSupport.Base.getFileInDataDirectory().

◆ getExternalDataDirectory()

TestSupport.Base.getExternalDataDirectory (   name,
  subDirectory = None 
)

Method to return path to the external data directory.

Sometimes test cases require large data that should not be added to the version control. The external data directories provide a solution for such situations. If the subDirectory parameter is not given the same folder structure is used like in the calling test case. If the data directory does not exist None is returned. @params name The name of the external data directory (FME or MMS for example). @params subDirectory The sub directory in the external data store.

Returns
The path to the directory where required data lives.

Definition at line 853 of file Base.py.

◆ getFileInDataDirectory()

TestSupport.Base.getFileInDataDirectory (   filename)

Returns the absolute filename of a file in the data directory using getDataDirectory().

Returns
The absolute filename of a file in the data directory.

Definition at line 826 of file Base.py.

References TestSupport.Base.getDataDirectory().

Referenced by TestSupport.Base.existsFileInDataDirectory().

◆ getHash()

TestSupport.Base.getHash (   filename,
  hash = "SHA1",
  encoder = "Hex" 
)

Compute a hash for the content of the given file.

The hash is computed using the ImageHash module for images and using python's hashlib for other files.

Parameters
filenameThe file that should be hashed.
hashThe hash algorithm to use.
encoderThe encoder to use.
Returns
The computed hash or None in case of failure.

Definition at line 906 of file Base.py.

◆ getModuleName()

TestSupport.Base.getModuleName ( )

Return the name of the currently tested module.

If the current test case is not a generic one None is returned.

Returns
The name of currently tested module.

Definition at line 114 of file Base.py.

References TestSupport.Base.getModuleName().

Referenced by TestSupport.Base.getModuleName().

◆ getPackageList()

TestSupport.Base.getPackageList ( )

Returns the list of available packages.

The list of packages that is said to be thought of being available. This is for example helpful if a developer has installed all the sources, but wants to verify only modules are used in seeAlso that are available in public installers.

Returns
List of packages that should be thought available.

Definition at line 91 of file Base.py.

References TestSupport.Base.getPackageList().

Referenced by TestSupport.Base.getPackageList().

◆ getResultDirectory()

TestSupport.Base.getResultDirectory ( )

Getter for the directory used to save results.

All results should be collected in the given directory such that the generated data will be cleaned up when appropriate.

Returns
Path to the result directory.

Definition at line 802 of file Base.py.

◆ getSourceFileEncoding()

TestSupport.Base.getSourceFileEncoding (   filename)

Definition at line 52 of file Base.py.

Referenced by TestSupport.Base.decodeSourceCodeLine().

◆ getTestCaseContext()

TestSupport.Base.getTestCaseContext ( )

Get the context of the test.

The context in which the current test is loaded. This is where the test related network is available.

Returns
The current test case's context.

Definition at line 103 of file Base.py.

References TestSupport.Base.getTestCaseContext().

Referenced by TestSupport.Base.getTestCaseContext().

◆ getTestFunctionName()

TestSupport.Base.getTestFunctionName ( )

Returns the name of the current test function.

Returns
The name of current test function.

Definition at line 123 of file Base.py.

◆ hardwareSupportsOffscreenRendering()

TestSupport.Base.hardwareSupportsOffscreenRendering ( )

Definition at line 1115 of file Base.py.

◆ hasError()

TestSupport.Base.hasError (   errorRegExp = None)

Expect that the expression in the context logs an error that matches errorRegExp.

If errorRegExp is not given, any error is expected.

Usage: with hasError(): doStuff()

Definition at line 741 of file Base.py.

◆ hasInfo()

TestSupport.Base.hasInfo (   infoRegExp = None,
  allowUnexpectedMessages = True 
)

Expect that the expression in the context logs an info entry that matches infoRegExp.

If infoRegExp is not given, any info message is expected. If allowUnexpectedMessages is set to True (the default), messages that do not match infoRegExp are ignored, otherwise they are considered a failure.

Usage: with hasInfo(infoRegExp=".*Unknown module.*"): doStuff()

Definition at line 777 of file Base.py.

◆ hasNoWarning()

TestSupport.Base.hasNoWarning (   warningRegExp = None)

Expect that the expression in the context block issues no warning that matches warningRegExp.

If warningRegExp is not given, no warning is expected at all.

Usage: with hasNoWarning(): doStuff()

Definition at line 707 of file Base.py.

◆ hasWarning()

TestSupport.Base.hasWarning (   warningRegExp = None)

Expect that the expression in the context block logs a warning that matches warningRegExp.

If warningRegExp is not given, any warning is expected.

Usage: with hasWarning(): doStuff()

Definition at line 724 of file Base.py.

◆ hasWarningAndError()

TestSupport.Base.hasWarningAndError (   errorRegExp = None,
  warningRegExp = None 
)

Expect that the expression in the context logs errors and warnings.

See hasError and hasWarning for the arguments.

Usage: with hasWarningAndError(): doStuff()

Definition at line 758 of file Base.py.

◆ ignoreError()

TestSupport.Base.ignoreError (   function,
  args = (),
  kwargs = None,
  errorRegExp = None,
  resultInfoDict = None,
kargs = None 
)

Call the given function with the given parameters and ignores potential errors.

USE WITH CARE, usually you want to use expectError for explicit error handling!

Please note that nesting the ignore{Warning, Error} methods will lead to invalid line numbers in the reports!

Parameters
functionThe function to be called.
argsList of parameters for the function.
kwargsDictionary of named parameters for the function.
errorRegExpOptional RegexObject to control which errors are ignored (non-matching ones will not be caught!). (Strings will be assumed to be regular expressions and compiled automatically.)
resultInfoDictOptional dictionary that, if provided, gets a new key 'hadIgnoredErrors' with a boolean value \ that allows the caller to react on whether there actually were errors or not
Returns
Return value of the called function.

Definition at line 588 of file Base.py.

◆ ignoreWarning()

TestSupport.Base.ignoreWarning (   function,
  args = (),
  kwargs = None,
  warningRegExp = None,
  resultInfoDict = None,
kargs = None 
)

Call the given function with the given parameters and ignores potential warnings.

USE WITH CARE, usually you want to use expectWarning for explicit warning handling!

Please note that nesting the ignore{Warning, Warning} methods will lead to invalid line numbers in the reports!

Parameters
functionThe function to be called.
argsList of parameters for the function.
kwargsDictionary of named parameters for the function.
warningRegExpOptional RegexObject to control which warnings are ignored (non-matching ones will not be caught!). (Strings will be assumed to be regular expressions and compiled automatically.)
resultInfoDictOptional dictionary that, if provided, gets a new key 'hadIgnoredWarnings' with a boolean value \ that allows the caller to react on whether there actually were warnings or not
Returns
Return value of the called function.

Definition at line 621 of file Base.py.

◆ ignoreWarningAndError()

TestSupport.Base.ignoreWarningAndError (   function,
  args = (),
  kwargs = None,
  errorRegExp = None,
  warningRegExp = None,
  resultInfoDict = None,
kargs = None 
)

Call the given function with the given parameters and ignore both a warning and an error.

USE WITH CARE, usually you want to use expectWarningAndError for explicit warning handling!

Please note that nesting the ignore{Warning, Error, Info} methods will lead to invalid line numbers in the reports!

Parameters
functionThe function to be called.
argsList of parameters for the function.
kwargsDictionary of named parameters for the function.
errorRegExpOptional RegexObject to control which errors are handled.
warningRegExpOptional RegexObject to control which warnings are handled.
resultInfoDictOptional dictionary that, if provided, gets new keys 'hadIgnoredWarnings' and 'hadIgnoredErrors' with boolean values that allow the caller to react on whether there actually were warnings/errors or not
Returns
Return value of the called function.

Definition at line 654 of file Base.py.

◆ LoggingDecorator()

TestSupport.Base.LoggingDecorator (   func)

Internal decorator used for creating messages in compare methods.

Definition at line 186 of file Base.py.

References TestSupport.Base.decodeSourceCodeLine().

◆ popChangeSet()

TestSupport.Base.popChangeSet ( )

Pop the last ChangeSet from the stack.

At least two ChangeSets (the global one and the one for the function) must remain on the stack as they are not in the control of the user.

Definition at line 889 of file Base.py.

References TestSupport.Base.popChangeSet().

Referenced by TestSupport.Base.popChangeSet().

◆ popEnvironment()

TestSupport.Base.popEnvironment ( )

Pops the last pushed environment dictionary from a stack and makes it the current one.

See pushEnvironment().

Returns
Returns if there was an environment dictionary to pop.

Definition at line 998 of file Base.py.

References TestSupport.Base.popEnvironment().

Referenced by TestSupport.Base.popEnvironment(), and TestSupport.Base.pushEnvironmentDecorator().

◆ pushChangeSet()

TestSupport.Base.pushChangeSet ( )

Push a new ChangeSet to the stack.

Definition at line 878 of file Base.py.

References TestSupport.Base.pushChangeSet().

Referenced by TestSupport.Base.pushChangeSet().

◆ pushEnvironment()

TestSupport.Base.pushEnvironment ( )

Pushes the current environment dictionary on a stack, so that modifications can be applied and be popped again later.

See popEnvironment().

Definition at line 987 of file Base.py.

References TestSupport.Base.pushEnvironment().

Referenced by TestSupport.Base.pushEnvironment(), and TestSupport.Base.pushEnvironmentDecorator().

◆ pushEnvironmentDecorator()

TestSupport.Base.pushEnvironmentDecorator (   func)

◆ runProcess()

TestSupport.Base.runProcess (   command,
  wait = True,
  expectSuccess = True,
  expectFailure = False,
  verbose = True,
  env = None 
)

Definition at line 1133 of file Base.py.

References TestSupport.Base.verifyProcessResult().

Referenced by TestSupport.Base.runPythonScript().

◆ runPythonScript()

TestSupport.Base.runPythonScript (   script,
  arguments,
  wait = True,
  expectSuccess = True,
  expectFailure = False,
  verbose = True,
  env = None 
)

Definition at line 1219 of file Base.py.

References TestSupport.Base.runProcess().

◆ setMacrosShouldLogOnSuccess()

TestSupport.Base.setMacrosShouldLogOnSuccess (   logOnSuccess)

Globally enables or disables if the ASSERT_*/EXPECT_* macros log an info message on success.

It does not have to be reset, because the TestCenter enables it before each TestCase.

For example:

def setUpTestCase():
setMacrosShouldLogOnSuccess(False)

Definition at line 145 of file Base.py.

Referenced by TestSupport.Base.MacrosShouldLogOnSuccessDecorator.__call__().

◆ shouldLogOnSuccess()

◆ verifyFalse()

TestSupport.Base.verifyFalse (   expr,
  comment = "",
  logOnSuccess = None,
  msg = None 
)

If the given expression evaluates to True, an error is logged.

Parameters
exprThe expression that must evaluate to False.
commentOptional comment shown if expression is True.
logOnSuccesPrint message in case of success.
Returns
True if expression evaluates to False.

Definition at line 481 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

◆ verifyProcessResult()

TestSupport.Base.verifyProcessResult (   command,
  shortCommand,
  returncode,
  stdout,
  stderr,
  expectSuccess = True,
  expectFailure = False,
  verbose = True 
)

Definition at line 1172 of file Base.py.

Referenced by TestSupport.Base.runProcess().

◆ verifyTrue()

TestSupport.Base.verifyTrue (   expr,
  comment = "",
  logOnSuccess = None,
  msg = None 
)

If the given expression evaluates to False, an error is logged.

Parameters
exprThe expression that must evaluate to True.
commentOptional comment shown if expression is not True.
logOnSuccesPrint message in case of success.
Returns
True if expression evaluates to True.

Definition at line 462 of file Base.py.

References TestSupport.Base.shouldLogOnSuccess().

Variable Documentation

◆ gEncodingCache

dict TestSupport.Base.gEncodingCache = {}

Definition at line 44 of file Base.py.

◆ gEncodingRegExp

TestSupport.Base.gEncodingRegExp = re.compile("^[ \t\v]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)")

Definition at line 43 of file Base.py.