示例#1
0
    def test_getVectorLegend(self):
        """Getting a legend for a vector layer works.
        @note This test is not related do thousand separator since we insert
        our own legend notes and our own layer.
        """
        myLayer, _ = load_layer('test_shakeimpact.shp')
        myMapLegend = MapLegend(
            myLayer,
            theLegendNotes='Thousand separator represented by \',\'',
            theLegendUnits='(people per cell)')
        myImage = myMapLegend.getVectorLegend()
        myPath = unique_filename(
            prefix='getVectorLegend',
            suffix='.png',
            dir=temp_dir('test'))
        myImage.save(myPath, 'PNG')
        LOGGER.debug(myPath)
        # As we have discovered, different versions of Qt and
        # OS platforms cause different output, so myControlImages is a list
        # of 'known good' renders.

        myTolerance = 0  # to allow for version number changes in disclaimer
        myFlag, myMessage = check_images(
            'getVectorLegend', 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