diff --git a/tests/python_tests/load_map_test.py b/tests/python_tests/load_map_test.py index 6126394d0..93195eb77 100644 --- a/tests/python_tests/load_map_test.py +++ b/tests/python_tests/load_map_test.py @@ -1,10 +1,9 @@ #!/usr/bin/python from nose.tools import * -from mapnik import Map, load_map from utilities import execution_path -import os, sys, glob +import os, sys, glob, mapnik def setup(): # All of the paths used are relative, if we run the tests @@ -14,24 +13,24 @@ def setup(): # We expect these files to not raise any # exceptions at all def assert_loads_successfully(file): - m = Map(512, 512) + m = mapnik.Map(512, 512) print "Loading %s" % (file) strict = True - load_map(m, file, strict) + mapnik.load_map(m, file, strict) # We expect these files to raise a UserWarning # and fail if there isn't one (or a different type # of exception) @raises(UserWarning) def assert_raises_userwarning(file): - m = Map(512, 512) + m = mapnik.Map(512, 512) print "Loading %s" % (file) strict = True - load_map(m, file, strict) + mapnik.load_map(m, file, strict) def test_broken_files(): broken_files = glob.glob("../data/broken_maps/*.xml") diff --git a/tests/python_tests/save_map_test.py b/tests/python_tests/save_map_test.py index e169a02a3..f989db972 100644 --- a/tests/python_tests/save_map_test.py +++ b/tests/python_tests/save_map_test.py @@ -1,10 +1,9 @@ #!/usr/bin/python -from mapnik import * from nose.tools import * from utilities import execution_path -import os, sys, glob +import os, sys, glob, mapnik def setup(): # All of the paths used are relative, if we run the tests @@ -17,22 +16,22 @@ def test(): # 2. Save map as XML # 3. Load map to a second object # 4. Compare both map objects - map = Map(256, 256) + map = mapnik.Map(256, 256) in_map = "../data/good_maps/osm-styles.xml" print "Loading map '%s' ... " % in_map - load_map(map, in_map) + mapnik.load_map(map, in_map) test_map = "test_map.xml" print "Saving map '%s' ... " % test_map - save_map(map, test_map) - new_map = Map(256, 256) + mapnik.save_map(map, test_map) + new_map = mapnik.Map(256, 256) print "Reloading map '%s' ... " % test_map - load_map(new_map, test_map) + mapnik.load_map(new_map, test_map) if os.path.exists(test_map): print "Removing '%s'" % test_map diff --git a/tests/run_tests.py b/tests/run_tests.py new file mode 100755 index 000000000..741384ffd --- /dev/null +++ b/tests/run_tests.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +import nose, sys, os, getopt + +def usage(): + print "test.py -h | --help" + print "test.py [-q | -v] [-p | --prefix ]" + +def main(): + try: + opts, args = getopt.getopt(sys.argv[1:], "hvqp:", ["help", "prefix="]) + except getopt.GetoptError, err: + print str(err) + usage() + sys.exit(2) + + prefix = None + verbose = False + quiet = False + + for o, a in opts: + if o == "-q": + quiet = True + elif o == "-v": + verbose = True + elif o in ("-h", "--help"): + usage() + sys.exit() + elif o in ("-p", "--prefix"): + prefix = a + else: + assert False, "unhandled option" + + if quiet and verbose: + usage() + sys.exit(2) + + if prefix: + # Allow python to find libraries for testing on the buildbot + sys.path.insert(0, os.path.join(prefix, "lib/python%s/site-packages" % sys.version[:3])) + + import mapnik + + if not quiet: + print "- mapnik path: %s" % mapnik.__file__ + print "- _mapnik.so path: %s" % mapnik._mapnik.__file__ + print "- Input plugins path: %s" % mapnik.inputpluginspath + print "- Font path: %s" % mapnik.fontscollectionpath + print + print "- Running nosetests:" + print + + argv = [__file__, '--exe'] + + if not quiet: + argv.append('-v') + + if verbose: + argv.append('-v') + argv.append('-v') + + nose.run(argv=argv) + +if __name__ == "__main__": + main()