35_mlab_do_not_reload = 
True   
   37gCurrentSpecialMessage = 
"" 
   38gSpecialMessageMarker = 
"<MLAB TC=1/>" 
   39gEnablePrettyLogging = 
False 
   40gLogInfoMessages = 
True 
   44    global gCurrentSpecialMessage
 
   45    msg = gCurrentSpecialMessage
 
   46    gCurrentSpecialMessage = 
"" 
 
   50def emitSpecialMessage(loggingMethod, file, line, type, message, escapeHtml=True, formattedStack=""):
 
   51    global gCurrentSpecialMessage
 
   53        escapedMsg = mevis.MLAB.escapeString(message)
 
   54        escapedMsg = escapedMsg.replace(
"\n", 
"<br>")
 
   58    if sys.version_info.major >= 3:
 
   59        if isinstance(formattedStack, str):
 
   60            formattedStack = formattedStack.encode()
 
   62    encodedStackTrace = str(base64.b64encode(formattedStack))
 
   64    specialMessage = 
"##M[%s|%s|%s|%s]: %s" % (file, line, type, encodedStackTrace, escapedMsg)
 
   65    if gEnablePrettyLogging:
 
   66        gCurrentSpecialMessage = specialMessage
 
   68            "<font style='font-weight:normal'><font color=black>" 
   69            + mevis.MLAB.createHyperLinkWithLine(file, line)
 
   75        escapedMsg += gSpecialMessageMarker
 
   76        loggingMethod(escapedMsg)
 
   78        loggingMethod(specialMessage)
 
 
   82    global gCurrentSpecialMessage
 
   84        escapedMsg = mevis.MLAB.escapeString(message)
 
   89    specialMessage = 
"##C[%s|%s|%s:%s] %s" % (file, line, type, 
",".join(fileList), str(escapedMsg))
 
   90    if gEnablePrettyLogging:
 
   91        gCurrentSpecialMessage = specialMessage
 
   93            "<font style='font-weight:normal'><font color=black>" 
   94            + mevis.MLAB.createHyperLinkWithLine(file, line)
 
  100        for fileInList 
in fileList:
 
  101            if "|" in fileInList:
 
  102                fileInList = fileInList[fileInList.index(
"|") + 1 :]
 
  103            escapedMsg += 
" " + mevis.MLAB.createHyperLink(fileInList)
 
  104        escapedMsg += gSpecialMessageMarker
 
  105        mevis.MLAB.logHTML(escapedMsg)
 
  107        mevis.MLAB.logHTML(specialMessage)
 
 
  111    """This decorator is used to specify the stack frame that is used to detect the location while logging. 
  112    It uses the stack frame that calls the given function. Functions with this decorator can call each other 
  113    recursively. The first stack frame of such a recursion is then used.""" 
  115    def setLoggingCallerStackFrameWrapper(*args, **kwargs):
 
  117            return func(*args, **kwargs)
 
  119    return setLoggingCallerStackFrameWrapper
 
 
  123IncreaseLoggingStackDepthDecorator = UseStackFrameFromCallerForLogging
 
  143        return sys._getframe(stackDepth + 1)
 
 
 
  159    def __init__(self, errorRegExp, logErrorFunc, preventReplacingMessageSeverity=False):
 
  162        handling = MessageHandling.EXPECT 
if logErrorFunc 
is not None else MessageHandling.IGNORE
 
 
  168    def __enableErrorHandling(self, enable):
 
  169        logHandler = TestHelper.getInstance().getLogHandler()
 
  180        mevis.MLAB.priv().flushPendingMessages()
 
  185        return hasCaughtError
 
 
 
  189    """Helper object to supress warnings. 
  190    Make sure that you call handleResult() in a finally: clause. 
  191    If no logErrorFunc it given, matching warnings will just be ignored, not expected, 
  192    so no error will be logged if no match was found. 
  195    def __init__(self, warningRegExp, logErrorFunc=None, expectWarning=True):
 
  197        handling = MessageHandling.EXPECT 
if logErrorFunc 
is not None else MessageHandling.IGNORE
 
 
  203    def __enableWarningHandling(self, enable):
 
  204        TestHelper.getInstance().getLogHandler().pushOrPopMessageFilter(enable, self.
__messageFilter)
 
  207        mevis.MLAB.priv().flushPendingMessages()
 
 
 
  222    def __init__(self, infoRegExp, allowUnexpectedMessages, logErrorFunc):
 
 
  229    def __enableInfoHandling(self, enable):
 
  230        TestHelper.getInstance().getLogHandler().pushOrPopMessageFilter(enable, self.
__messageFilter)
 
  233        mevis.MLAB.priv().flushPendingMessages()
 
  237        if hadUnexpectedInfo:
 
  240        if not hadExpectedInfo:
 
 
 
  250        ChangeSet.__init__(self, context)
 
 
  256        def wrapper(*args, **kwds):
 
  258                loggingMethod, message = func(*args, **kwds)
 
  259                if gLogInfoMessages 
or (loggingMethod != mevis.MLAB.logHTML):
 
  260                    stackFrame = TestHelper.getInstance().getCallerStackFrame()
 
  261                    stackLine = traceback.extract_stack(stackFrame, 1)[0]
 
  262                    emitSpecialMessage(loggingMethod, stackLine[0], stackLine[1], 
"ChangeSet", message, escapeHtml=
True)
 
 
  271        return mevis.MLAB.logHTML, message
 
 
  278        return mevis.MLAB.logErrorHTML, message
 
 
 
  303    _mTestCaseContext = 
None 
  305    _mHelperModule = 
None 
  307    _mResultDirectory = 
None 
  312    _mTestCaseName = 
None 
  317    _mTestCaseDataDirectory = 
None 
  319    _mTestCaseResultDirectory = 
None 
  322    _mChangeSetStack = 
None 
  325    _mSecureTesting = 
False 
  334    _mEnvironmentStack = 
None 
  337    _mExtraTestCaseResults = 
None 
  340    _mMacrosLogOnSuccess = 
True 
  343    __lockObj = _thread.allocate_lock()
 
  368        """Static method to have a reference to **THE UNIQUE** instance""" 
  369        if len(kargs) 
not in (0, 2):
 
  371                "Singleton's getInstance must be called with context and result directory arguments or without any!" 
  374        initialize = len(kargs) == 2
 
  380                if not "context" in kargs 
or not "resultDir" in kargs:
 
  381                    raise Exception(
"Singleton must be initialized with context and result directory!")
 
  386                """Initialize object **here**, as you would do in __init__()...""" 
  388                self.
_mCtx = kargs[
"context"]
 
  393                self.
_mHelperModule = self.
_mCtx.addModule(mevis.MLAB.moduleLiteral(
"TestCenterHelperModule"))
 
 
  513        if functionName != 
None:
 
 
  554            changeSet.enableAutoRevert(
False)
 
 
  653        os.environ = dict(os.environ)
 
 
 
Class to handle field changes and make them revertable.
 
__enableInfoHandling(self, enable)
 
__init__(self, infoRegExp, allowUnexpectedMessages, logErrorFunc)
 
__allowUnexpectedMessages
 
__init__(self, stackDepth)
 
getCallingStackFrame(self, stackDepth)
 
__preventReplacingMessageSeverity
 
__previousKeepMessageSeverity
 
__enableErrorHandling(self, enable)
 
__init__(self, errorRegExp, logErrorFunc, preventReplacingMessageSeverity=False)
 
__enableWarningHandling(self, enable)
 
__init__(self, warningRegExp, logErrorFunc=None, expectWarning=True)
 
__init__(self, context)
The default constructor.
 
pushChangeSet(self)
Push a new ChangeSet to the stack.
 
popEnvironment(self)
Pops an environment dictionary from the stack and makes it the current environment.
 
getLogHandler(self)
Get the current log handler.
 
getCallerStackFrame(self)
 
bool _mSecureTesting
Allow checking, whether tests are run in secure mode.
 
_mStackFrame
The stack frame of the calling function that is used when logging events.
 
takeExtraTestCaseResults(self)
 
_mHelperModule
The context of the helper module.
 
_mTestCaseName
The name of the current test case.
 
setLogHandler(self, logHandler)
Set the current log handler.
 
setTestCaseName(self, testCaseName)
 
_mChangeSetStack
A stack of ChangeSets used to revert changes to field values.
 
_mExtraTestCaseResults
A list of extra test case results.
 
setMacrosLogOnSuccess(self, macrosLogOnSuccess)
 
bool _mMacrosLogOnSuccess
This is the default value for the 'logOnSuccess' parameter (if it is None) of the ASSERT_*/EXPECT_* m...
 
__new__(self, *args, **kargs)
The new method.
 
clearChangeSet(self)
Clear the change set stakc without restoring the field values.
 
popChangeSet(self)
Pop a ChangeSet from the stack and delete it.
 
__init__(self, *args, **kargs)
The default constructor.
 
_mEnvironmentStack
A stack of environment dictionaries used to revert changes to the environment.
 
setModuleName(self, moduleName)
 
hasCallerStackFrame(self)
 
_mModuleName
The name of the currently tested module.
 
setTestCaseContext(self, ctx)
Set the context of the test.
 
getChangeSet(self)
Return the ChangeSet on top of the stack.
 
_mTestCaseContext
The current test's context.
 
runTestInCurrentMlabInstance(self)
Set if tests are not run in secure mode.
 
getChangeSetStackLength(self)
Get the length of the ChangeSet stack.
 
getTestCaseResultDirectory(self)
 
_mTestCaseDataDirectory
The path to the test case data.
 
setPackageList(self, packageList)
Set the list of available packages.
 
getMacrosLogOnSuccess(self)
 
addExtraTestCaseResult(self, extraTestCaseResult)
 
setCallerStackFrame(self, stackFrame)
 
getTestCaseDataDirectory(self)
 
resetCallerStackFrame(self)
 
pushEnvironment(self)
Pushes the current environment to the stack.
 
testIsRunInSecureMode(self)
Check if tests are run in secure mode.
 
setTestCaseResultDirectory(self, testCaseName, functionName)
 
hasInstance(self)
Check if an instance has been initialized.
 
getPackageList(self)
Return the list of available packages.
 
unsetLogHandler(self)
Unset the current log handler.
 
setTestCaseDataDirectory(self, testCaseDataPath)
 
_mPackageList
The list of packages that should be assumed to be available.
 
getTestCaseContext(self)
Get the context of the test.
 
getInstance(self, *args, **kargs)
The default constructor.
 
_mTestCaseResultDirectory
The path to the results.
 
_mLogHandler
The log handler that can be used to handle the reports.
 
runTestInSecureMode(self)
Set if tests are run in secure mode.
 
_mResultDirectory
The directory used to save results.
 
emitSpecialMessage(loggingMethod, file, line, type, message, escapeHtml=True, formattedStack="")
 
emitSpecialCommand(file, line, type, fileList, message, escapeHtml=True)
 
UseStackFrameFromCallerForLogging(func)
 
takeCurrentSpecialMessage()