示例#1
0
 def test_addClassToLegend(self):
     """Test we can add a class to the map legend."""
     myLayer, _ = load_layer('test_shakeimpact.shp')
     myMapLegend = MapLegend(myLayer)
     myColour = QtGui.QColor(12, 34, 126)
     myMapLegend.addClassToLegend(
         myColour,
         theLabel='bar')
     myMapLegend.addClassToLegend(
         myColour,
         theLabel='foo')
     myPath = unique_filename(
         prefix='addClassToLegend',
         suffix='.png',
         dir=temp_dir('test'))
     myMapLegend.getLegend().save(myPath, 'PNG')
     LOGGER.debug(myPath)
     # As we have discovered, different versions of Qt and
     # OS platforms cause different output, so place any other possible
     # variants in the safe_qgis/test_data/test_images/ dir e.g.
     # addClassToLegend-variantUbuntu13.04.png
     myTolerance = 0  # to allow for version number changes in disclaimer
     myFlag, myMessage = check_images('addClassToLegend', myPath,
                                     myTolerance)
     myMessage += (
         '\nWe want these images to match, if they do already copy the test'
         ' image generated to create a new control image.')
     assert myFlag, myMessage