Add run_tests.py, a utility for running the test framework (useful for buildbot). Some formatting in the tests.
This commit is contained in:
parent
364b6f72c5
commit
3c13918ce8
3 changed files with 75 additions and 13 deletions
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
64
tests/run_tests.py
Executable file
64
tests/run_tests.py
Executable file
|
@ -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 <path>]"
|
||||
|
||||
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()
|
Loading…
Reference in a new issue