Package schrodinger :: Package test :: Package squish :: Package maestro :: Module exception_handling
[hide private]
[frames] | no frames]

Module exception_handling

Exception handling. Functions to trap Maestro and Python exceptions/failures and report them to the log file. Requires use of squish_modules/general/general.py

Rationale: At some points in Squish tests, it is useful to catch exceptions in try...except blocks. This only really makes sense if the later steps don't depend on the earlier steps.

For example:

   try:
       do stuff....
   except Exception as E:
       except_fail("Doing stuff failed.", E)
   else:
       test.passes("Doing stuff completed.")

Equivalently:

    with ContinueIfFails("Doing stuff failed."):
        do stuff....

To use, add the following to the top of your test.py:

source(findFile("scripts", "maestro/exception_handling.py"))

Will append necessary objects to your objects.map. If one of the required names is already defined in your objects.map, it will not overwrite it unless you set OVERWRITE_OBJECTS=True before importing this module.

Copyright (c) Schrodinger, LLC. All rights reserved

Classes [hide private]
  ContinueIfFails
Functions [hide private]
 
except_fail(output=None, E=None)
When passed an Exception, print a fail message to the Squish log.
 
handleDialogBox(dialog)
 
handleNonWarnings(messageBox)
 
handleMessageBox(messageBox)
 
handleMessageBoxLogWarnings(messageBox)
 
add_to_ignore_list(jira_id, pattern)
Adds to the list of regular expressions used by catchTerminalErrors to filter Maestro stderr.
 
catchTerminalErrors(obj)
Polls stderr for unexpected terminal output during test execution.
 
start_maestro(profile="Maestro", timeout=long_wait, warnings_as_failures=True, catch_stderr=False)
Waits for Maestro to open.
 
quit_maestro(ctx=None)
Quits Maestro and logs stdout and all filtered stderr (stderr not reported by catchTerminalErrors eventHandler).
 
clear_jobcontrol()
clear the jobdb and then kill the jserver
 
cleanup()
Cleans up after running test.main.
Variables [hide private]
  OVERWRITE_OBJECTS = False
hash(x)
  MAE_PROFILE_DIR = ""
  _JC_DO_NOT_DISTURB = False
hash(x)
  _ENABLE_WINDOWS_REMOTEJC = False
hash(x)
  _MAESTRO_STDERR_STORED = ''
  _IGNORE_STDERR = {}
  _SQUISH_REGEX = '^INFO.*[\r\n]*|' '^WARNING.*[\r\n]*|' '^Hook....
  _SQUISH_REGEX_COMPILED = re.compile(_SQUISH_REGEX, re.M)
Function Details [hide private]

catchTerminalErrors(obj)

 

Polls stderr for unexpected terminal output during test execution. Implemented by event handler keyed from QMouseEvent so that the obj passed to this function should be whatever object was clicked most recently. Sometimes the object clicked will have no symbolic name so we log both real and symbolic names to aid in debugging.

start_maestro(profile="Maestro", timeout=long_wait, warnings_as_failures=True, catch_stderr=False)

 

Waits for Maestro to open.  Closes any Maestro exception windows and
records their contents as failures to the log file,  To use this function,
make sure that your test does not start the AUT automatically!

@param profile : Type of profile to launch, ex. start_maestro("Elements"),
            default Maestro
@param timeout : The length of time to wait (msec, default long_wait)
@return : A Squish applicationcontext object to allow extraction of runtime
            information.
@rtype : squish.applicationContext

cleanup()

 

Cleans up after running test.main. Note that squish runs this function after main is run, even if the main was aborted (say, due to an uncaught exception)


Variables Details [hide private]

_SQUISH_REGEX

Value:
'^INFO.*[\r\n]*|' '^WARNING.*[\r\n]*|' '^Hook.*[\r\n]*|' '^QObject del\
eted before qt_removeObject overload.*[\r\n]*|' '^Please set your syst\
em display options to at least 32-bit color.*[\r\n]*|' '^Unable to loa\
d library icui18n.*[\r\n]*|' '^$[\r\n]*'