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

Module general

General constants and function overrides for use with Squish. Should use this in almost every Squish test. Also includes functions to delete files from the AUT directory and to update the object.map

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

source(findFile("scripts", "general/general.py"))

Copyright (c) Schrodinger, LLC. All rights reserved

Functions [hide private]
 
delete_paths(context, *args)
Deletes all files or directories passed in on the command line.
 
add_to_object_map(objects, directory="..", mapname="objects.map", overwrite=False)
Adds the dictionary of symbolic name->real names to the object map.
 
test_compare(val1, operator, val2, passMsg, failMsg)
A compare function that takes a boolean operator and reports the outcome to the Squish log file if pass or failure messages are provided.
 
wait_for_exists(object_name, time_out_msec=default_wait)
The default Squish waitForObject waits until an object exists and is enabled/available.
 
wait_for_file(filename, timeout=default_wait)
Waits until filename is available on the filesystem.
 
log_screenshots(func)
This is a function decorator for 'main' function in test.py.
Variables [hide private]
  short_wait = 3000
  default_wait = 20000
  long_wait = 300000
  extra_long_wait = 600000
Function Details [hide private]

delete_paths(context, *args)

 

Deletes all files or directories passed in on the command line. Uses AUT's CWD as starting point for any relative paths. Missing files are silently ignored.

All inputs are globbed into files, so valid invocations include: delete_paths(pathname1), delete_paths(pathname1, pathname2), delete_paths(pathname*)

Raises an error if anything requested is not a file or if the AUT has not yet been started.

add_to_object_map(objects, directory="..", mapname="objects.map", overwrite=False)

 

Adds the dictionary of symbolic name->real names to the object map. Loads the new objects.map.

If the symbolic name to be added already exists in your objects.map, its real-name definition will not be modified unless you specify overwrite=True. This does, however, overwrite your objects.map, so you will lose all formatting and comments.

The default directory is "..", because the Python script is launched from the test subdirectory, and the objects.map is in the suite directory.

Parameters:
  • objects - A dictionary of real names keyed off symbolic names to be added to the objects.map
  • directory - The directory in which the objects.map is located (default ..)
  • mapname - The name of your objects map file (default objects.map)
  • overwrite - Whether to overwrite the user's existing object definitions

test_compare(val1, operator, val2, passMsg, failMsg)

 

A compare function that takes a boolean operator and reports the outcome to the Squish log file if pass or failure messages are provided. Written as an improvement over Squish native test.compare allowing specification of success and failure and ability to use all python logical operators.

Parameters:
  • val1 (any) - The first value in the boolean expression
  • operator (str) - The boolean operator
  • val2 (any) - The second value in the boolean expression
  • passMsg (str) - Squish log file message on success
  • failMsg (str @return : Pass or failure @rtype : bool) - Squish log file message on failure

wait_for_exists(object_name, time_out_msec=default_wait)

 

The default Squish waitForObject waits until an object exists and is enabled/available. This function only waits for existance.

wait_for_file(filename, timeout=default_wait)

 

Waits until filename is available on the filesystem.

filename is a string of the absolute path to the file or a path to the file from the CWD.

timeout is an integer wait in milliseconds. This should be a short wait, for example 3000-5000 milliseconds.

log_screenshots(func)

 

This is a function decorator for 'main' function in test.py. This turns the
testSettings.logScreenshotOnError and testSettings.logScreenshoOnFail on and
then turns off once the test case execution is completed.

Usage:
     @log_screenshots
     def main():
         start_maestro()
         # Rest of the test case.