Skip to content


Model testing and command line arguments for test suite.
Browse files Browse the repository at this point in the history
git-svn-id: 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information committed Jul 9, 2012
1 parent 79d1a4f commit 843285d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/sextante/tests/
@@ -1 +1 @@
PYTHONPATH=~/Proyectos/qgis/output/python/:~/Proyectos/qgis/python/plugins/ python
PYTHONPATH=~/Proyectos/qgis/output/python/:~/Proyectos/qgis/python/plugins/ python $@
51 changes: 41 additions & 10 deletions src/sextante/tests/
Expand Up @@ -46,6 +46,7 @@
from sextante.outputs.OutputRaster import OutputRaster
from sextante.outputs.OutputVector import OutputVector
from sextante.core.SextanteConfig import SextanteConfig
from sextante.modeler.ModelerAlgorithm import ModelerAlgorithm

class DataProviderStub:
Expand Down Expand Up @@ -163,28 +164,58 @@ def tearDown(self):
print bcolors.ENDC

def algSuite():
def algSuite(dialog = "none", threaded = True, unthreaded = True, provider = None, algName = None):
s = unittest.TestSuite()
for provider, algs in Sextante.algs.items():
if not algs.items():
print bcolors.WARNING, "WARNING: %s seems to provide no algs!" % provider,
print bcolors.ENDC
algId, alg = algs.items()[-1]
s.addTest(SextanteProviderTestCase(algId, alg, True))
s.addTest(SextanteProviderTestCase(algId, alg, False))
s.addTest(SextanteProviderTestCase(algId, alg, True, "parameters"))
s.addTest(SextanteProviderTestCase(algId, alg, False, "parameters"))
algId, alg = algs.items()[-1]
if threaded:
s.addTest(SextanteProviderTestCase(algId, alg, True, dialog))
if unthreaded:
s.addTest(SextanteProviderTestCase(algId, alg, False, dialog))
return s

def modelSuite(modelFile, threaded = True, unthreaded = True):
s = unittest.TestSuite()
model = ModelerAlgorithm()
s.addTest(SextanteProviderTestCase(modelFile, model, True))
return s

if __name__ == '__main__':
if not os.path.exists("data/raster") or not os.path.exists("data/vector"):
print "Please install test data under ./data/raster and ./data/vector."
import argparse

parser = argparse.ArgumentParser(description='Sextante test suite.')
parser.add_argument('-l', action='store_true', help='Test sextante loading only. Ignore further arguments.')
#~ parser.add_argument('-a', dest='algorithm', help='Test a particular alg.')
#~ parser.add_argument('-p', dest='provider', help='Test a particular provider.')
parser.add_argument('-m', dest='model', help='Test a particular model.', default=None)
parser.add_argument('-d', dest='dialog', help='Test a particular dialog.', default = "none")
parser.add_argument('-t', dest='tOnly', action='store_true', help='Enable threaded execution only.')
parser.add_argument('-u', dest='uOnly', action='store_true', help='Enable unthreaded execution only.')
parser.add_argument('-r', dest='raster', help='Use specified raster as input.', default='data/raster')
parser.add_argument('-v', dest='vector', help='Use specified vectro as input.', default='data/vector')

args = parser.parse_args()

threaded = not args.uOnly or args.tOnly
unthreaded = not args.tOnly or args.uOnly

loadSuite = unittest.TestLoader().loadTestsFromTestCase(SextantePluginTest)
if args.l:
if not os.path.exists(args.raster) or not os.path.exists(args.vector):
print "No data under %s or %s. Run with -h argument for help" % (args.raster, args.vector)
if args.model:
unittest.TextTestRunner(verbosity=2).run(modelSuite(args.model or 'data/model', threaded, unthreaded))
unittest.TextTestRunner(verbosity=2).run(algSuite(args.dialog, threaded, unthreaded))
except KeyboardInterrupt:
print bcolors.ENDC, "Test interrupted."

0 comments on commit 843285d

Please sign in to comment.