mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
tests: support regenerating test images in more python tests
This commit is contained in:
parent
f0b0ee3e7e
commit
d9e49fd09a
@ -89,7 +89,7 @@ if mapnik.has_pycairo():
|
||||
draw_title(m,context,"Hello Map",size=20)
|
||||
draw_neatline(m,context)
|
||||
surface.finish()
|
||||
if not os.path.exists(expected_cairo_file):
|
||||
if not os.path.exists(expected_cairo_file) or os.environ.get('UPDATE'):
|
||||
print 'generated expected cairo surface file %s' % expected_cairo_file
|
||||
shutil.copy(test_cairo_file,expected_cairo_file)
|
||||
diff = abs(os.stat(expected_cairo_file).st_size-os.stat(test_cairo_file).st_size)
|
||||
@ -108,7 +108,7 @@ if mapnik.has_pycairo():
|
||||
draw_title(m,context,"Hello Map",size=20)
|
||||
draw_neatline(m,context)
|
||||
surface.finish()
|
||||
if not os.path.exists(expected_cairo_file):
|
||||
if not os.path.exists(expected_cairo_file) or os.environ.get('UPDATE'):
|
||||
print 'generated expected cairo surface file %s' % expected_cairo_file
|
||||
shutil.copy(test_cairo_file,expected_cairo_file)
|
||||
diff = abs(os.stat(expected_cairo_file).st_size-os.stat(test_cairo_file).st_size)
|
||||
@ -132,14 +132,14 @@ if mapnik.has_pycairo():
|
||||
im = mapnik.Image.from_cairo(surface)
|
||||
im.save(reduced_color_image,'png8')
|
||||
surface.finish()
|
||||
if not os.path.exists(expected_cairo_file):
|
||||
if not os.path.exists(expected_cairo_file) or os.environ.get('UPDATE'):
|
||||
print 'generated expected cairo surface file %s' % expected_cairo_file
|
||||
shutil.copy(test_cairo_file,expected_cairo_file)
|
||||
diff = abs(os.stat(expected_cairo_file).st_size-os.stat(test_cairo_file).st_size)
|
||||
msg = 'diff in size (%s) between actual (%s) and expected(%s)' % (diff,test_cairo_file,'tests/python_tests/'+ expected_cairo_file)
|
||||
eq_( diff < 500, True, msg)
|
||||
os.remove(test_cairo_file)
|
||||
if not os.path.exists(expected_cairo_file2):
|
||||
if not os.path.exists(expected_cairo_file2) or os.environ.get('UPDATE'):
|
||||
print 'generated expected cairo surface file %s' % expected_cairo_file2
|
||||
shutil.copy(reduced_color_image,expected_cairo_file2)
|
||||
diff = abs(os.stat(expected_cairo_file2).st_size-os.stat(reduced_color_image).st_size)
|
||||
@ -158,7 +158,7 @@ if mapnik.has_pycairo():
|
||||
surface = getattr(cairo,'%sSurface' % type.upper())(test_cairo_file, m.width,m.height)
|
||||
mapnik.render(m, surface)
|
||||
surface.finish()
|
||||
if not os.path.exists(expected_cairo_file):
|
||||
if not os.path.exists(expected_cairo_file) or os.environ.get('UPDATE'):
|
||||
print 'generated expected cairo surface file %s' % expected_cairo_file
|
||||
shutil.copy(test_cairo_file,expected_cairo_file)
|
||||
diff = abs(os.stat(expected_cairo_file).st_size-os.stat(test_cairo_file).st_size)
|
||||
|
||||
@ -41,7 +41,7 @@ if mapnik.has_png():
|
||||
def gen_filepath(name,format):
|
||||
return os.path.join('images/support/encoding-opts',name+'-'+format.replace(":","+")+'.png')
|
||||
|
||||
generate = False
|
||||
generate = os.environ.get('UPDATE')
|
||||
|
||||
def test_expected_encodings():
|
||||
# blank image
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user