Skip to content

Commit cbf47bd

Browse files
committed
Update tests [WIP] [skip ci]
1 parent 8ba5a61 commit cbf47bd

7 files changed

Lines changed: 23 additions & 22 deletions

test/python_tests/agg_rasterizer_integer_overflow_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_that_coordinates_do_not_overflow_and_polygon_is_rendered_memory():
2727
r = mapnik.Rule()
2828
sym = mapnik.PolygonSymbolizer()
2929
sym.fill = expected_color
30-
r.symbols.append(sym)
30+
r.symbolizers.append(sym)
3131
s.rules.append(r)
3232
lyr = mapnik.Layer('Layer', projection)
3333
lyr.datasource = ds
@@ -58,7 +58,7 @@ def test_that_coordinates_do_not_overflow_and_polygon_is_rendered_csv():
5858
r = mapnik.Rule()
5959
sym = mapnik.PolygonSymbolizer()
6060
sym.fill = expected_color
61-
r.symbols.append(sym)
61+
r.symbolizers.append(sym)
6262
s.rules.append(r)
6363
lyr = mapnik.Layer('Layer', projection)
6464
lyr.datasource = ds

test/python_tests/buffer_clear_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
def test_clearing_image_data():
55
im = mapnik.Image(256, 256)
66
# make sure it equals itself
7-
bytes = im.tostring()
8-
assert im.tostring() == bytes
7+
bytes = im.to_string()
8+
assert im.to_string() == bytes
99
# set background, then clear
1010
im.fill(mapnik.Color('green'))
11-
assert not im.tostring() == bytes
11+
assert not im.to_string() == bytes
1212
# clear image, should now equal original
1313
im.clear()
14-
assert im.tostring() == bytes
14+
assert im.to_string() == bytes
1515

1616
def make_map():
1717
ds = mapnik.MemoryDatasource()

test/python_tests/compositing_test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ def validate_pixels_are_premultiplied(image):
8888
def test_compare_images(setup):
8989
b = mapnik.Image.open('images/support/b.png')
9090
b.premultiply()
91-
num_ops = len(mapnik.CompositeOp.names)
91+
num_ops = len(mapnik.CompositeOp.__members__)
9292
successes = []
9393
fails = []
94-
for name in mapnik.CompositeOp.names:
94+
for name in mapnik.CompositeOp.__members__.keys():
9595
a = mapnik.Image.open('images/support/a.png')
9696
a.premultiply()
9797
a.composite(b, getattr(mapnik.CompositeOp, name))
@@ -112,7 +112,7 @@ def test_compare_images(setup):
112112
a.save(expected, 'png32')
113113
expected_im = mapnik.Image.open(expected)
114114
# compare them
115-
if a.tostring('png32') == expected_im.tostring('png32'):
115+
if a.to_string('png32') == expected_im.to_string('png32'):
116116
successes.append(name)
117117
else:
118118
fails.append(
@@ -130,7 +130,7 @@ def test_compare_images(setup):
130130
# TODO - write test to ensure the image is 99% the same.
131131
#expected_b = mapnik.Image.open('./images/support/b.png')
132132
# b.save('/tmp/mapnik-comp-op-test-original-mask.png')
133-
#assert 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'
133+
#assert b.to_string('png32') == expected_b.to_string('png32'), '/tmp/mapnik-comp-op-test-original-mask.png is no longer equivalent to original mask: ./images/support/b.png'
134134

135135

136136
def test_pre_multiply_status():
@@ -179,7 +179,8 @@ def test_style_level_comp_op():
179179
m.zoom_all()
180180
successes = []
181181
fails = []
182-
for name in mapnik.CompositeOp.names:
182+
183+
for name in mapnik.CompositeOp.__members__.keys():
183184
# find_style returns a copy of the style object
184185
style_markers = m.find_style("markers")
185186
style_markers.comp_op = getattr(mapnik.CompositeOp, name)
@@ -195,7 +196,7 @@ def test_style_level_comp_op():
195196
im.save(expected, 'png32')
196197
expected_im = mapnik.Image.open(expected)
197198
# compare them
198-
if im.tostring('png32') == expected_im.tostring('png32'):
199+
if im.to_string('png32') == expected_im.to_string('png32'):
199200
successes.append(name)
200201
else:
201202
fails.append(
@@ -220,7 +221,7 @@ def test_style_level_opacity():
220221
expected = 'images/support/mapnik-style-level-opacity.png'
221222
im.save(actual, 'png32')
222223
expected_im = mapnik.Image.open(expected)
223-
assert im.tostring('png32') == expected_im.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual,
224+
assert im.to_string('png32') == expected_im.to_string('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual,
224225
'tests/python_tests/' + expected)
225226

226227

test/python_tests/image_filters_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_style_level_image_filter(setup):
5454
im.save(expected, 'png32')
5555
expected_im = mapnik.Image.open(expected)
5656
# compare them
57-
if im.tostring('png32') == expected_im.tostring('png32'):
57+
if im.to_string('png32') == expected_im.to_string('png32'):
5858
successes.append(name)
5959
else:
6060
fails.append(

test/python_tests/introspection_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ def test_introspect_symbolizers(setup):
2020

2121
assert p.allow_overlap == True
2222
assert p.opacity == 0.5
23-
assert p.filename == '../data/images/dummy.png'
23+
assert p.file == '../data/images/dummy.png'
2424

2525
# make sure the defaults
2626
# are what we think they are
2727
assert p.allow_overlap == True
2828
assert p.opacity == 0.5
29-
assert p.filename == '../data/images/dummy.png'
29+
assert p.file == '../data/images/dummy.png'
3030

3131
# contruct objects to hold it
3232
r = mapnik.Rule()
33-
r.symbols.append(p)
33+
r.symbolizers.append(p)
3434
s = mapnik.Style()
3535
s.rules.append(r)
3636
m = mapnik.Map(0, 0)
@@ -44,7 +44,7 @@ def test_introspect_symbolizers(setup):
4444
rules = s2.rules
4545
assert len(rules) == 1
4646
r2 = rules[0]
47-
syms = r2.symbols
47+
syms = r2.symbolizers
4848
assert len(syms) == 1
4949

5050
# TODO here, we can do...
@@ -54,4 +54,4 @@ def test_introspect_symbolizers(setup):
5454

5555
assert p2.allow_overlap == True
5656
assert p2.opacity == 0.5
57-
assert p2.filename == '../data/images/dummy.png'
57+
assert p2.file == '../data/images/dummy.png'

test/python_tests/layer_buffer_size_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def test_layer_buffer_size_1(setup):
2929
expected = 'images/support/mapnik-layer-buffer-size.png'
3030
im.save(actual, "png32")
3131
expected_im = mapnik.Image.open(expected)
32-
assert im.tostring('png32') == expected_im.tostring('png32'),'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/' + expected)
32+
assert im.to_string('png32') == expected_im.to_string('png32'),'failed comparing actual (%s) and expected (%s)' % (actual,'tests/python_tests/' + expected)

test/python_tests/markers_complex_rendering_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_marker_ellipse_render1(setup):
2323
if os.environ.get('UPDATE'):
2424
im.save(expected, 'png32')
2525
expected_im = mapnik.Image.open(expected)
26-
assert im.tostring('png32') == expected_im.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual, expected)
26+
assert im.to_string('png32') == expected_im.to_string('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual, expected)
2727

2828
def test_marker_ellipse_render2():
2929
m = mapnik.Map(256, 256)
@@ -37,4 +37,4 @@ def test_marker_ellipse_render2():
3737
if os.environ.get('UPDATE'):
3838
im.save(expected, 'png32')
3939
expected_im = mapnik.Image.open(expected)
40-
assert im.tostring('png32') == expected_im.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual, expected)
40+
assert im.to_string('png32') == expected_im.to_string('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual, expected)

0 commit comments

Comments
 (0)