tests: prefer testing png encoded bytes

This commit is contained in:
Dane Springmeyer 2013-11-22 16:41:46 -08:00
parent 529095d739
commit 3e69c337d2
6 changed files with 14 additions and 14 deletions

View file

@ -98,7 +98,7 @@ def test_compare_images():
a.save(expected) a.save(expected)
expected_im = mapnik.Image.open(expected) expected_im = mapnik.Image.open(expected)
# compare them # compare them
if a.tostring() == expected_im.tostring(): if a.tostring('png32') == expected_im.tostring('png32'):
successes.append(name) successes.append(name)
else: else:
fails.append('failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected)) fails.append('failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected))
@ -110,7 +110,7 @@ def test_compare_images():
# TODO - write test to ensure the image is 99% the same. # TODO - write test to ensure the image is 99% the same.
#expected_b = mapnik.Image.open('./images/support/b.png') #expected_b = mapnik.Image.open('./images/support/b.png')
#b.save('/tmp/mapnik-comp-op-test-original-mask.png') #b.save('/tmp/mapnik-comp-op-test-original-mask.png')
#eq_(b.tostring(),expected_b.tostring(), '/tmp/mapnik-comp-op-test-original-mask.png is no longer equivalent to original mask: ./images/support/b.png') #eq_(b.tostring('png32'),expected_b.tostring('png32'), '/tmp/mapnik-comp-op-test-original-mask.png is no longer equivalent to original mask: ./images/support/b.png')
def test_pre_multiply_status(): def test_pre_multiply_status():
b = mapnik.Image.open('./images/support/b.png') b = mapnik.Image.open('./images/support/b.png')
@ -172,7 +172,7 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
im.save(expected) im.save(expected)
expected_im = mapnik.Image.open(expected) expected_im = mapnik.Image.open(expected)
# compare them # compare them
if im.tostring() == expected_im.tostring(): if im.tostring('png32') == expected_im.tostring('png32'):
successes.append(name) successes.append(name)
else: else:
fails.append('failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected)) fails.append('failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected))
@ -190,7 +190,7 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
expected = 'images/support/mapnik-style-level-opacity.png' expected = 'images/support/mapnik-style-level-opacity.png'
im.save(actual) im.save(actual)
expected_im = mapnik.Image.open(expected) expected_im = mapnik.Image.open(expected)
eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected)) eq_(im.tostring('png32'),expected_im.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected))
def test_rounding_and_color_expectations(): def test_rounding_and_color_expectations():
m = mapnik.Map(1,1) m = mapnik.Map(1,1)

View file

@ -55,7 +55,7 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
im.save(expected) im.save(expected)
expected_im = mapnik.Image.open(expected) expected_im = mapnik.Image.open(expected)
# compare them # compare them
if im.tostring() == expected_im.tostring(): if im.tostring('png32') == expected_im.tostring('png32'):
successes.append(name) successes.append(name)
else: else:
fails.append('failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected)) fails.append('failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected))

View file

@ -27,7 +27,7 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names():
expected = 'images/support/mapnik-layer-buffer-size.png' expected = 'images/support/mapnik-layer-buffer-size.png'
im.save(actual) im.save(actual)
expected_im = mapnik.Image.open(expected) expected_im = mapnik.Image.open(expected)
eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected)) eq_(im.tostring('png32'),expected_im.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected))
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -20,7 +20,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
expected = 'images/support/mapnik-marker-ellipse-render1.png' expected = 'images/support/mapnik-marker-ellipse-render1.png'
im.save(actual) im.save(actual)
expected_im = mapnik.Image.open(expected) expected_im = mapnik.Image.open(expected)
eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected)) eq_(im.tostring('png32'),expected_im.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected))
def test_marker_ellipse_render2(): def test_marker_ellipse_render2():
# currently crashes https://github.com/mapnik/mapnik/issues/1365 # currently crashes https://github.com/mapnik/mapnik/issues/1365
@ -33,7 +33,7 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
expected = 'images/support/mapnik-marker-ellipse-render2.png' expected = 'images/support/mapnik-marker-ellipse-render2.png'
im.save(actual) im.save(actual)
expected_im = mapnik.Image.open(expected) expected_im = mapnik.Image.open(expected)
eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected)) eq_(im.tostring('png32'),expected_im.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected))
if __name__ == "__main__": if __name__ == "__main__":
setup() setup()

View file

@ -53,8 +53,8 @@ if mapnik.has_png():
im.save(expected,opt) im.save(expected,opt)
else: else:
im.save(actual,opt) im.save(actual,opt)
eq_(mapnik.Image.open(actual).tostring(), eq_(mapnik.Image.open(actual).tostring('png32'),
mapnik.Image.open(expected).tostring(), mapnik.Image.open(expected).tostring('png32'),
'%s (actual) not == to %s (expected)' % (actual,expected)) '%s (actual) not == to %s (expected)' % (actual,expected))
for opt in opts: for opt in opts:
@ -65,8 +65,8 @@ if mapnik.has_png():
im.save(expected,opt) im.save(expected,opt)
else: else:
im.save(actual,opt) im.save(actual,opt)
eq_(mapnik.Image.open(actual).tostring(), eq_(mapnik.Image.open(actual).tostring('png32'),
mapnik.Image.open(expected).tostring(), mapnik.Image.open(expected).tostring('png32'),
'%s (actual) not == to %s (expected)' % (actual,expected)) '%s (actual) not == to %s (expected)' % (actual,expected))
def test_transparency_levels(): def test_transparency_levels():

View file

@ -139,7 +139,7 @@ if 'python' in mapnik.DatasourceCache.plugin_names():
expected = 'images/support/mapnik-python-point-render1.png' expected = 'images/support/mapnik-python-point-render1.png'
im.save(actual) im.save(actual)
expected_im = mapnik.Image.open(expected) expected_im = mapnik.Image.open(expected)
eq_(im.tostring(),expected_im.tostring(), eq_(im.tostring('png32'),expected_im.tostring('png32'),
'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected)) 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected))
def test_python_circle_rendering(): def test_python_circle_rendering():
@ -152,7 +152,7 @@ if 'python' in mapnik.DatasourceCache.plugin_names():
expected = 'images/support/mapnik-python-circle-render1.png' expected = 'images/support/mapnik-python-circle-render1.png'
im.save(actual) im.save(actual)
expected_im = mapnik.Image.open(expected) expected_im = mapnik.Image.open(expected)
eq_(im.tostring(),expected_im.tostring(), eq_(im.tostring('png32'),expected_im.tostring('png32'),
'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected)) 'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/'+ expected))
if __name__ == "__main__": if __name__ == "__main__":