[GRASS-SVN] r49191 - grass-addons/grass7/raster/r.agent
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 13 10:23:07 EST 2011
Author: mic
Date: 2011-11-13 07:23:07 -0800 (Sun, 13 Nov 2011)
New Revision: 49191
Added:
grass-addons/grass7/raster/r.agent/libold/
grass-addons/grass7/raster/r.agent/tests.py
Log:
prepare refactoring
Added: grass-addons/grass7/raster/r.agent/tests.py
===================================================================
--- grass-addons/grass7/raster/r.agent/tests.py (rev 0)
+++ grass-addons/grass7/raster/r.agent/tests.py 2011-11-13 15:23:07 UTC (rev 49191)
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE: r.agent.aco
+# AUTHOR(S): michael lustenberger inofix.ch
+# PURPOSE: r.agent.aco is used to organize ant-like agents in a raster
+# based playground. As decribed by the Ant Colony Optimization
+# algorithm, the ants wander around looking for attractors,
+# marking their paths if they find any.
+# COPYRIGHT: (C) 2011 by Michael Lustenberger and the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+
+def dotest(function, argv):
+ """Global wrapper for the individual test suits."""
+ while True:
+ n = function.func_doc
+ o = str(argv)
+ if not n:
+ n = str(function)
+ t = str(raw_input("execute this now: '"+n+" - "+o+"'? [y/n/abort] "))
+ if t == "y":
+ if argv != None:
+ function(*argv)
+ else:
+ function()
+ break
+ elif t == "n":
+ break
+ elif t == "abort":
+ exit()
+
+def testError(expr, msg):
+ """Test suite for Class: Error"""
+ try:
+ raise error.DataError(expr, msg)
+ except error.DataError:
+ print "catched! all fine."
+
+def testPlayground():
+ """Test suite for Class: Playground"""
+ pg = playground.Playground()
+
+def testWorld():
+ """Test suite for Class: World"""
+ w = world.World()
+
+
+if __name__ == "__main__":
+ """Main method for testing when run as a script."""
+ import sys
+ from libagent import error
+ from libagent import playground
+ from libagent import world
+
+ alltests = {"error":[testError, ["Error Test Suite", "(this error is good)"]],
+ "playground":[testPlayground, []],
+ "world":[testWorld, []]}
+
+ if len(sys.argv) == 1:
+ for test,details in alltests.iteritems():
+ dotest(details[0], details[1])
+ else:
+ sys.argv.pop(0)
+ for t in sys.argv:
+ if t in alltests:
+ dotest(*alltests[t])
+ else:
+ print("Test does not exist: ", t)
+
+
Property changes on: grass-addons/grass7/raster/r.agent/tests.py
___________________________________________________________________
Added: svn:executable
+ *
More information about the grass-commit
mailing list