forked from mapnik/python-mapnik
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert even more unit tests to use pytest [WIP]
- Loading branch information
Showing
9 changed files
with
390 additions
and
617 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,22 @@ | ||
# coding=utf8 | ||
import os | ||
|
||
from nose.tools import eq_ | ||
|
||
import mapnik | ||
|
||
from .utilities import execution_path, run_all | ||
|
||
|
||
def setup(): | ||
# All of the paths used are relative, if we run the tests | ||
# from another directory we need to chdir() | ||
os.chdir(execution_path('.')) | ||
|
||
if 'sqlite' in mapnik.DatasourceCache.plugin_names(): | ||
|
||
# the negative buffer on the layer should | ||
# override the postive map buffer leading | ||
# only one point to be rendered in the map | ||
def test_layer_buffer_size_1(): | ||
m = mapnik.Map(512, 512) | ||
eq_(m.buffer_size, 0) | ||
mapnik.load_map(m, '../data/good_maps/layer_buffer_size_reduction.xml') | ||
eq_(m.buffer_size, 256) | ||
eq_(m.layers[0].buffer_size, -150) | ||
assert m.buffer_size == 0 | ||
mapnik.load_map(m, './test/data/good_maps/layer_buffer_size_reduction.xml') | ||
assert m.buffer_size == 256 | ||
assert m.layers[0].buffer_size == -150 | ||
m.zoom_all() | ||
im = mapnik.Image(m.width, m.height) | ||
mapnik.render(m, im) | ||
actual = '/tmp/mapnik-layer-buffer-size.png' | ||
expected = 'images/support/mapnik-layer-buffer-size.png' | ||
expected = './test/python_tests/images/support/mapnik-layer-buffer-size.png' | ||
im.save(actual, "png32") | ||
expected_im = mapnik.Image.open(expected) | ||
eq_(im.tostring('png32'), | ||
expected_im.tostring('png32'), | ||
'failed comparing actual (%s) and expected (%s)' % (actual, | ||
'tests/python_tests/' + expected)) | ||
|
||
|
||
if __name__ == "__main__": | ||
setup() | ||
exit(run_all(eval(x) for x in dir() if x.startswith("test_"))) | ||
assert im.tostring('png32') == expected_im.tostring('png32'),'failed comparing actual (%s) and expected (%s)' % (actual, | ||
'tests/python_tests/' + expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,21 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from nose.tools import eq_ | ||
|
||
import mapnik | ||
|
||
from .utilities import run_all | ||
|
||
|
||
# Map initialization | ||
|
||
|
||
def test_layer_init(): | ||
l = mapnik.Layer('test') | ||
eq_(l.name, 'test') | ||
eq_(l.srs, 'epsg:4326') | ||
eq_(l.envelope(), mapnik.Box2d()) | ||
eq_(l.clear_label_cache, False) | ||
eq_(l.cache_features, False) | ||
eq_(l.visible(1), True) | ||
eq_(l.active, True) | ||
eq_(l.datasource, None) | ||
eq_(l.queryable, False) | ||
eq_(l.minimum_scale_denominator, 0.0) | ||
eq_(l.maximum_scale_denominator > 1e+6, True) | ||
eq_(l.group_by, "") | ||
eq_(l.maximum_extent, None) | ||
eq_(l.buffer_size, None) | ||
eq_(len(l.styles), 0) | ||
|
||
if __name__ == "__main__": | ||
exit(run_all(eval(x) for x in dir() if x.startswith("test_"))) | ||
assert l.name == 'test' | ||
assert l.srs == 'epsg:4326' | ||
assert l.envelope() == mapnik.Box2d() | ||
assert not l.clear_label_cache | ||
assert not l.cache_features | ||
assert l.visible(1) | ||
assert l.active | ||
assert l.datasource == None | ||
assert not l.queryable | ||
assert l.minimum_scale_denominator == 0.0 | ||
assert l.maximum_scale_denominator > 1e+6 | ||
assert l.group_by == "" | ||
assert l.maximum_extent == None | ||
assert l.buffer_size == None | ||
assert len(l.styles) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.