Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some colors in test the understand what's going on.
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@283 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com committed Jul 4, 2012
1 parent 33f1349 commit 1190830
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/sextante/core/Sextante.py
Expand Up @@ -369,6 +369,7 @@ def error(msg):
QApplication.restoreOverrideCursor()
QMessageBox.critical(None, "Error", msg)
SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
cancel();
def cancel():
try:
algEx.finished.disconnect()
Expand Down
25 changes: 18 additions & 7 deletions src/sextante/tests/test.py
Expand Up @@ -50,6 +50,12 @@ class DataProviderStub:
def __init__(self, uri):
self.dataSourceUri = lambda: uri

class bcolors:
INFO = '\033[94m'
WARNING = '\033[91m'
ENDC = '\033[0m'


class SextantePluginTest(unittest.TestCase):
"""Test suite for Sextante QGis plugin"""

Expand Down Expand Up @@ -90,7 +96,7 @@ def gen_test_parameters(self, alg):
yield p.min
yield 42
elif isinstance(p, ParameterString):
yield str()
yield "Test string"
elif isinstance(p, ParameterBoolean):
b = not b
yield b
Expand All @@ -112,9 +118,10 @@ def gen_test_parameters(self, alg):
def test_runalg(self):
SextanteConfig.setSettingValue(SextanteConfig.USE_THREADS, self.threaded)
args = list(self.gen_test_parameters(self.alg))
print
print self.msg, "Parameters: ", self.alg.parameters, ' => ', args
print
print bcolors.INFO, self.msg, bcolors.ENDC, "Parameters: ", self.alg.parameters, ' => ', args, bcolors.WARNING,
result = Sextante.runalg(self.algId, *args)
print bcolors.ENDC
self.assertIsNotNone(result, self.msg)
if not result:
return
Expand All @@ -126,7 +133,8 @@ def algSuite():
s = unittest.TestSuite()
for provider, algs in Sextante.algs.items():
if not algs.items():
print "WARNING: %s seems to provide no algs!" % provider
print bcolors.WARNING, "WARNING: %s seems to provide no algs!" % provider,
print bcolors.ENDC
continue
algId, alg = algs.items()[-1]
s.addTest(SextanteProviderTestCase(algId, alg, True))
Expand All @@ -137,7 +145,10 @@ def algSuite():
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."
exit(1)
loadSuite = unittest.TestLoader().loadTestsFromTestCase(SextantePluginTest)
unittest.TextTestRunner(verbosity=2).run(loadSuite)
unittest.TextTestRunner(verbosity=2).run(algSuite())
try:
loadSuite = unittest.TestLoader().loadTestsFromTestCase(SextantePluginTest)
unittest.TextTestRunner(verbosity=2).run(loadSuite)
unittest.TextTestRunner(verbosity=2).run(algSuite())
except KeyboardInterrupt:
print bcolors.ENDC, "Test interrupted."

0 comments on commit 1190830

Please sign in to comment.