Skip to content

Commit d6e8d1b

Browse files
committed
Unit tests - markers + image-filters [WIP]
1 parent 6727f11 commit d6e8d1b

20 files changed

Lines changed: 51 additions & 110 deletions
Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,23 @@
1-
#!/usr/bin/env python
2-
3-
import os
4-
import re
5-
6-
from nose.tools import eq_
7-
1+
import re, os
82
import mapnik
9-
10-
from .utilities import execution_path, run_all, side_by_side_image
11-
12-
13-
def setup():
14-
# All of the paths used are relative, if we run the tests
15-
# from another directory we need to chdir()
16-
os.chdir(execution_path('.'))
17-
3+
from .utilities import side_by_side_image
184

195
def replace_style(m, name, style):
206
m.remove_style(name)
217
m.append_style(name, style)
228

23-
249
def test_append():
2510
s = mapnik.Style()
26-
eq_(s.image_filters, '')
11+
assert s.image_filters == ''
2712
s.image_filters = 'gray'
28-
eq_(s.image_filters, 'gray')
13+
assert s.image_filters == 'gray'
2914
s.image_filters = 'sharpen'
30-
eq_(s.image_filters, 'sharpen')
15+
assert s.image_filters == 'sharpen'
3116

3217
if 'shape' in mapnik.DatasourceCache.plugin_names():
3318
def test_style_level_image_filter():
3419
m = mapnik.Map(256, 256)
35-
mapnik.load_map(m, '../data/good_maps/style_level_image_filter.xml')
20+
mapnik.load_map(m, './test/data/good_maps/style_level_image_filter.xml')
3621
m.zoom_all()
3722
successes = []
3823
fails = []
@@ -54,7 +39,7 @@ def test_style_level_image_filter():
5439
im = mapnik.Image(m.width, m.height)
5540
mapnik.render(m, im)
5641
actual = '/tmp/mapnik-style-image-filter-' + filename + '.png'
57-
expected = 'images/style-image-filter/' + filename + '.png'
42+
expected = './test/python_tests/images/style-image-filter/' + filename + '.png'
5843
im.save(actual, "png32")
5944
if not os.path.exists(expected) or os.environ.get('UPDATE'):
6045
print('generating expected test image: %s' % expected)
@@ -66,15 +51,11 @@ def test_style_level_image_filter():
6651
else:
6752
fails.append(
6853
'failed comparing actual (%s) and expected(%s)' %
69-
(actual, 'tests/python_tests/' + expected))
54+
(actual, expected))
7055
fail_im = side_by_side_image(expected_im, im)
7156
fail_im.save(
7257
'/tmp/mapnik-style-image-filter-' +
7358
filename +
7459
'.fail.png',
7560
'png32')
76-
eq_(len(fails), 0, '\n' + '\n'.join(fails))
77-
78-
if __name__ == "__main__":
79-
setup()
80-
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))
61+
assert len(fails) == 0, '\n' + '\n'.join(fails)
-11 Bytes
Loading
8 Bytes
Loading
-3 Bytes
Loading
-18 Bytes
Loading
-22 Bytes
Loading
-9 Bytes
Loading
-23 Bytes
Loading
-16 Bytes
Loading
-24 Bytes
Loading

0 commit comments

Comments
 (0)