### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe_qgis »

# Module: safe_qgis.utilities_test

Helper module for gui test suite

class `safe_qgis.utilities_test.``RedirectStdStreams`(stdout=None, stderr=None)

  Context manager for redirection of stdout and stderr

  This is from http://stackoverflow.com/questions/6796492/ python-temporarily-redirect-stdout-stderr

  In this context, the class is used to get rid of QGIS output in the test suite - BUT IT DOESN’T WORK (Maybe because QGIS starts its providers in a different process?)

  Usage:

  devnull = open(os.devnull, ‘w’) print(‘Fubar’)

  with RedirectStdStreams(stdout=devnull, stderr=devnull):
    print(“You’ll never see me”)

  print(“I’m back!”)

`safe_qgis.utilities_test.``assertHashForFile`(theHash, theFilename)

  Assert that a files has matches its expected hash

`safe_qgis.utilities_test.``assertHashesForFile`(theHashes, theFilename)

  Assert that a files has matches one of a list of expected hashes

`safe_qgis.utilities_test.``getQgisTestApp`()

  Start one QGis application to test agaist

  Input
    NIL
  Output
    handle to qgis app

  If QGis is already running the handle to that app will be returned

`safe_qgis.utilities_test.``hashForFile`(theFilename)

  Return an md5 checksum for a file

`safe_qgis.utilities_test.``loadLayer`(theLayerFile, theDirectory='/home/timlinux/dev/python/inasafe_data/test')

  Helper to load and return a single QGIS layer

  Args:

    theLayerFile: Pathname to raster or vector file DIR: Optional parameter stating the parent dir. If None,

    > pathname is assumed to be absolute

  Returns: QgsMapLayer, str (for layer type)

`safe_qgis.utilities_test.``setBatemansBayGeoExtent`()

  Zoom to an area occupied by both Batemans Bay layers in geo crs

`safe_qgis.utilities_test.``setCanvasCrs`(theEpsgId, theOtfpFlag=False)

  Helper to set the crs for the CANVAS before a test is run.

  Args:

  > - theEpsgId - Valid EPSG identifier (int)

  > - theOtfpFlag - whether on the fly projections should be enabled

  >     on the CANVAS. Default to False.

`safe_qgis.utilities_test.``setGeoExtent`(theBoundingBox)

  Zoom to an area specified given bounding box (list)

`safe_qgis.utilities_test.``setJakartaGeoExtent`()

  Zoom to an area occupied by both Jakarta layers in Geo

`safe_qgis.utilities_test.``setJakartaGoogleExtent`()

  Zoom to an area occupied by both Jakarta layers in 900913 crs

`safe_qgis.utilities_test.``setPadangGeoExtent`()

  Zoom to an area occupied by both both Padang layers

`safe_qgis.utilities_test.``setYogyaGeoExtent`()

  Zoom to an area occupied by both Jakarta layers in Geo

`safe_qgis.utilities_test.``unitTestDataPath`(theSubdir=None)

  Return the absolute path to the InaSAFE unit test data dir.

  Note

  This is not the same thing as the SVN inasafe_data dir. Rather this is a new dataset where the test datasets are all tiny for fast testing and the datasets live in the same repo as the code.

  Args:
    - theSubdir: (Optional) Additional subdir to add to the path - typically ‘hazard’ or ‘exposure’.

This module forms part of the InaSAFE tool.

### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe_qgis »