fixup a variety of image comparison tests and expected results

This commit is contained in:
Dane Springmeyer 2014-01-27 14:21:07 -08:00
parent a98de6a348
commit beb65664f7
11 changed files with 12 additions and 11 deletions

View file

@ -49,7 +49,7 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
mapnik.render(m, im)
actual = '/tmp/mapnik-style-image-filter-' + filename + '.png'
expected = 'images/style-image-filter/' + filename + '.png'
im.save(actual)
im.save(actual,"png32")
if not os.path.exists(expected):
print 'generating expected test image: %s' % expected
im.save(expected)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -30,7 +30,6 @@ def test_render_image_to_string():
eq_(im.is_solid(),True)
s = im.tostring()
eq_(s, 256 * 256 * '\x00\x00\x00\xff')
s = im.tostring('png')
def test_non_solid_image():
im = mapnik.Image(256, 256)
@ -61,16 +60,18 @@ def test_setting_alpha():
w,h = 256,256
im1 = mapnik.Image(w,h)
# white, half transparent
im1.background = mapnik.Color('rgba(255,255,255,.5)')
c1 = mapnik.Color('rgba(255,255,255,.5)')
im1.background = c1
eq_(im1.painted(),False)
eq_(im1.is_solid(),True)
# pure white
im2 = mapnik.Image(w,h)
im2.background = mapnik.Color('rgba(255,255,255,1)')
im2.set_alpha(.5)
c2 = mapnik.Color('rgba(255,255,255,1)')
im2.background = c2
im2.set_alpha(c1.a/255.0)
eq_(im2.painted(),False)
eq_(im2.is_solid(),True)
eq_(len(im1.tostring()), len(im2.tostring()))
eq_(len(im1.tostring('png32')), len(im2.tostring('png32')))
def test_render_image_to_file():
im = mapnik.Image(256, 256)
@ -106,10 +107,10 @@ def get_paired_images(w,h,mapfile):
def test_render_from_serialization():
try:
im,im2 = get_paired_images(100,100,'../data/good_maps/building_symbolizer.xml')
eq_(im.tostring(),im2.tostring())
eq_(im.tostring('png32'),im2.tostring('png32'))
im,im2 = get_paired_images(100,100,'../data/good_maps/polygon_symbolizer.xml')
eq_(im.tostring(),im2.tostring())
eq_(im.tostring('png32'),im2.tostring('png32'))
except RuntimeError, e:
# only test datasources that we have installed
if not 'Could not create datasource' in str(e):
@ -199,7 +200,7 @@ def test_render_with_detector():
im.save(actual_file,'png8')
actual = mapnik.Image.open(expected_file)
expected = mapnik.Image.open(expected_file)
eq_(actual.tostring(),expected.tostring(), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
# now render will a collision detector that should
# block out the placement of this point
detector = mapnik.LabelCollisionDetector(m)
@ -229,11 +230,11 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
expected_file = './images/support/marker-text-line-scale-factor-%s.png' % size
actual_file = '/tmp/' + os.path.basename(expected_file)
im.save(actual_file,'png32')
#im.save(expected_file,'png32')
im.save(expected_file,'png32')
# we save and re-open here so both png8 images are ready as full color png
actual = mapnik.Image.open(actual_file)
expected = mapnik.Image.open(expected_file)
eq_(actual.tostring(),expected.tostring(), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
if __name__ == "__main__":
setup()