From 74877c87782284aa64d7b4eb05e68eaacaaac058 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 30 Aug 2011 22:51:42 +0000 Subject: [PATCH] test touchups to ensure they can all be run individually --- tests/python_tests/cairo_test.py | 4 ++++ tests/python_tests/datasource_test.py | 3 ++- tests/python_tests/feature_id_test.py | 5 +---- tests/python_tests/feature_test.py | 3 +++ tests/python_tests/filter_test.py | 2 ++ tests/python_tests/font_test.py | 3 +++ tests/python_tests/glyph_symbolizer_test.py | 6 +++++- tests/python_tests/introspection_test.py | 14 +++++++++++++- tests/python_tests/layer_modification_test.py | 15 +++++++++++++-- tests/python_tests/load_map_test.py | 4 ++++ tests/python_tests/memory_datasource_test.py | 3 +++ tests/python_tests/object_test.py | 13 ++++++++++++- tests/python_tests/projection_test.py | 3 +++ tests/python_tests/raster_colorizer_test.py | 17 +++++++++++------ tests/python_tests/raster_symbolizer_test.py | 3 +++ tests/python_tests/render_grid_test.py | 3 +-- tests/python_tests/render_test.py | 13 +++++++++++-- tests/python_tests/save_map_test.py | 4 ++++ 18 files changed, 98 insertions(+), 20 deletions(-) diff --git a/tests/python_tests/cairo_test.py b/tests/python_tests/cairo_test.py index 1968582d2..95a1755be 100644 --- a/tests/python_tests/cairo_test.py +++ b/tests/python_tests/cairo_test.py @@ -53,3 +53,7 @@ def test_pycairo_svg_surface(): def test_pycairo_svg_surface(): return _pycairo_surface('ps','polygon') + +if __name__ == "__main__": + setup() + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/datasource_test.py b/tests/python_tests/datasource_test.py index ac12d64a7..4d84b3346 100644 --- a/tests/python_tests/datasource_test.py +++ b/tests/python_tests/datasource_test.py @@ -86,4 +86,5 @@ def test_hit_grid(): eq_(hit_list[-12:],'1:Chile|812:') if __name__ == '__main__': - test_hit_grid() \ No newline at end of file + setup() + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/feature_id_test.py b/tests/python_tests/feature_id_test.py index 7bfbb897f..2db7e9bcc 100644 --- a/tests/python_tests/feature_id_test.py +++ b/tests/python_tests/feature_id_test.py @@ -66,7 +66,4 @@ def test_feature_hit_count(): if __name__ == "__main__": setup() - test_shapefile_line_featureset_id() - test_shapefile_polygon_featureset_id() - test_shapefile_polygon_feature_query_id() - test_feature_hit_count() \ No newline at end of file + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/feature_test.py b/tests/python_tests/feature_test.py index e690c419b..f41fac5fa 100644 --- a/tests/python_tests/feature_test.py +++ b/tests/python_tests/feature_test.py @@ -50,3 +50,6 @@ class FeatureTest(unittest.TestCase): self.failUnlessEqual(env.miny, env.maxy) add_it(Geometry2d.from_wkt('Point(3 6)')) + +if __name__ == "__main__": + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/filter_test.py b/tests/python_tests/filter_test.py index 02b532179..025961122 100644 --- a/tests/python_tests/filter_test.py +++ b/tests/python_tests/filter_test.py @@ -118,5 +118,7 @@ def test_unicode_regex_replace(): expr = mapnik2.Expression("[name].replace('(\B)|( )','$1 ')") eq_(expr.evaluate(f),'Q u é b e c') +if __name__ == "__main__": + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/font_test.py b/tests/python_tests/font_test.py index b0164522e..8603bdfbb 100644 --- a/tests/python_tests/font_test.py +++ b/tests/python_tests/font_test.py @@ -11,3 +11,6 @@ import mapnik2, pickle #@raises(UserWarning) #def test_invalid_font(): # ts = mapnik2.TextSymbolizer('Name', 'Invalid Font Name', int(8), mapnik2.Color('black')) + +if __name__ == "__main__": + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/glyph_symbolizer_test.py b/tests/python_tests/glyph_symbolizer_test.py index 9ab5ad63e..48c35cc2c 100644 --- a/tests/python_tests/glyph_symbolizer_test.py +++ b/tests/python_tests/glyph_symbolizer_test.py @@ -2,6 +2,7 @@ #!/usr/bin/env python from nose.tools import * + from utilities import execution_path, save_data, contains_word import os, mapnik2 @@ -52,7 +53,6 @@ def test_load_save_load_map(): map = mapnik2.Map(256,256) mapnik2.load_map_from_string(map, out_map.encode('utf8')) assert 'GlyphSymbolizer' in out_map - assert 'RasterColorizer' in out_map # make sure non-ascii characters are well supported since most interesting # glyphs for symbology are usually in that range assert u'í' in out_map, out_map @@ -93,3 +93,7 @@ def create_map_and_append_symbolyzer(sym): _map.zoom_to_box(mapnik2.Box2d(0,0,8,8)) return _map +if __name__ == "__main__": + setup() + [eval(run)() for run in dir() if 'test_' in run] + diff --git a/tests/python_tests/introspection_test.py b/tests/python_tests/introspection_test.py index cc8706d20..2eec53fcf 100644 --- a/tests/python_tests/introspection_test.py +++ b/tests/python_tests/introspection_test.py @@ -1,10 +1,17 @@ #!/usr/bin/env python +import os from nose.tools import * +from utilities import execution_path from utilities import Todo import mapnik2 +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('.')) + def test_introspect_symbolizers(): # create a symbolizer p = mapnik2.PointSymbolizer(mapnik2.PathExpression("../data/images/dummy.png")) @@ -57,4 +64,9 @@ def test_introspect_symbolizers(): eq_(p2.allow_overlap, True) eq_(p2.opacity, 0.5) - eq_(p2.filename,'../data/images/dummy.png') \ No newline at end of file + eq_(p2.filename,'../data/images/dummy.png') + + +if __name__ == "__main__": + setup() + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/layer_modification_test.py b/tests/python_tests/layer_modification_test.py index 3e4a5d802..f25cbb2c4 100644 --- a/tests/python_tests/layer_modification_test.py +++ b/tests/python_tests/layer_modification_test.py @@ -2,8 +2,16 @@ from nose.tools import * +import os +from nose.tools import * +from utilities import execution_path import mapnik2 +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('.')) + def test_adding_datasource_to_layer(): map_string = ''' @@ -58,6 +66,9 @@ def test_adding_datasource_to_layer(): # test that assignment eq_(m.layers[0].srs,'+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs') eq_(lyr.srs,'+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs') - - + +if __name__ == "__main__": + setup() + [eval(run)() for run in dir() if 'test_' in run] + \ No newline at end of file diff --git a/tests/python_tests/load_map_test.py b/tests/python_tests/load_map_test.py index a2eebe757..6b902dfc4 100644 --- a/tests/python_tests/load_map_test.py +++ b/tests/python_tests/load_map_test.py @@ -48,3 +48,7 @@ def test_good_files(): for file in good_files: yield assert_loads_successfully, file + +if __name__ == "__main__": + setup() + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/memory_datasource_test.py b/tests/python_tests/memory_datasource_test.py index 339b103a3..6c835f6d6 100644 --- a/tests/python_tests/memory_datasource_test.py +++ b/tests/python_tests/memory_datasource_test.py @@ -38,3 +38,6 @@ class MemoryDatasource(unittest.TestCase): retrieved = md.features_at_point(Coord(20,30)).features self.failUnlessEqual(len(retrieved), 0) + +if __name__ == "__main__": + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/object_test.py b/tests/python_tests/object_test.py index 7bf95ba54..b93603748 100644 --- a/tests/python_tests/object_test.py +++ b/tests/python_tests/object_test.py @@ -1,10 +1,17 @@ #!/usr/bin/env python +import os from nose.tools import * +from utilities import execution_path from utilities import Todo import mapnik2, pickle +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('.')) + # Tests that exercise the functionality of Mapnik classes. # ShieldSymbolizer initialization @@ -742,4 +749,8 @@ def test_envelope_pickle(): e2 = mapnik2.Box2d(173.7378, -39.6395, 174.4849, -38.9252) e1.clip(e2) eq_(e1,e2) - + +if __name__ == "__main__": + setup() + [eval(run)() for run in dir() if 'test_' in run] + diff --git a/tests/python_tests/projection_test.py b/tests/python_tests/projection_test.py index a9160f8b4..c2e7c820b 100644 --- a/tests/python_tests/projection_test.py +++ b/tests/python_tests/projection_test.py @@ -45,3 +45,6 @@ def test_wgs84_inverse_forward(): assert_almost_equal(e.forward(p).center().y, e.center().y) assert_almost_equal(e.forward(p).center().x, e.center().x) + +if __name__ == "__main__": + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/raster_colorizer_test.py b/tests/python_tests/raster_colorizer_test.py index 2c35dff93..70e9e5036 100644 --- a/tests/python_tests/raster_colorizer_test.py +++ b/tests/python_tests/raster_colorizer_test.py @@ -1,6 +1,13 @@ +import os import mapnik2 +from utilities import execution_path from nose.tools import * +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('.')) + def test_gen_map(): mapxmlfile = '../data/good_maps/raster_colorizer.xml' mapxmloutputfile = 'raster_colorizer_test_save.xml' @@ -12,10 +19,6 @@ def test_gen_map(): m.zoom_all() mapnik2.render_to_file(m, outputfile) - - - - #test discrete colorizer mode def test_get_color_discrete(): #setup @@ -39,8 +42,6 @@ def test_get_color_discrete(): #now in stop 2 eq_(colorizer.get_color(20), mapnik2.Color(200,200,200,200)); eq_(colorizer.get_color(1000), mapnik2.Color(200,200,200,200)); - - #test exact colorizer mode def test_get_color_exact(): @@ -92,4 +93,8 @@ def test_get_color_linear(): #after stop 2 eq_(colorizer.get_color(100), mapnik2.Color(200,200,200,200)); +if __name__ == "__main__": + setup() + [eval(run)() for run in dir() if 'test_' in run] + diff --git a/tests/python_tests/raster_symbolizer_test.py b/tests/python_tests/raster_symbolizer_test.py index 24c7cc456..6e8f442e7 100644 --- a/tests/python_tests/raster_symbolizer_test.py +++ b/tests/python_tests/raster_symbolizer_test.py @@ -132,3 +132,6 @@ def test_raster_with_alpha_blends_correctly_with_background(): # All white is expected assert contains_word('\xff\xff\xff\xff', imdata) +if __name__ == "__main__": + setup() + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/render_grid_test.py b/tests/python_tests/render_grid_test.py index 64da10f2b..12a29a0dd 100644 --- a/tests/python_tests/render_grid_test.py +++ b/tests/python_tests/render_grid_test.py @@ -143,5 +143,4 @@ def test_render_grid2(): eq_(resolve(utf5,38,46),{"Name": "South East"}) if __name__ == "__main__": - test_render_grid() - test_render_grid2() \ No newline at end of file + [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/python_tests/render_test.py b/tests/python_tests/render_test.py index 3a9bfefc6..2724e1492 100644 --- a/tests/python_tests/render_test.py +++ b/tests/python_tests/render_test.py @@ -4,8 +4,17 @@ from nose.tools import * import os, mapnik2 +from nose.tools import * + +from utilities import execution_path from utilities import Todo +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('.')) + + def test_simplest_render(): m = mapnik2.Map(256, 256) i = mapnik2.Image(m.width, m.height) @@ -210,6 +219,6 @@ def test_render_points(): num_points_rendered = svg.count('