[GRASS-SVN] r67964 - in grass/trunk/raster/r.grow.distance: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Feb 26 07:01:54 PST 2016
Author: lucadelu
Date: 2016-02-26 07:01:54 -0800 (Fri, 26 Feb 2016)
New Revision: 67964
Added:
grass/trunk/raster/r.grow.distance/testsuite/
grass/trunk/raster/r.grow.distance/testsuite/r_grow_distance_test.py
Log:
r.grow.distance: added test thanks to aandre (#2937)
Added: grass/trunk/raster/r.grow.distance/testsuite/r_grow_distance_test.py
===================================================================
--- grass/trunk/raster/r.grow.distance/testsuite/r_grow_distance_test.py (rev 0)
+++ grass/trunk/raster/r.grow.distance/testsuite/r_grow_distance_test.py 2016-02-26 15:01:54 UTC (rev 67964)
@@ -0,0 +1,52 @@
+"""
+Name: r_grow_distance_test
+Purpose: This script is to demonstrate a unit test for r.grow.distance
+ module.
+"""
+
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+
+class TestGrowDistance(TestCase):
+ """Test case for grow distance module"""
+
+ # Setup variables to be used for outputs
+ distance = 'test_distance'
+ lakes = 'lakes'
+ elevation = 'elevation'
+
+ @classmethod
+ def setUpClass(cls):
+ """Ensures expected computational region and setup"""
+ # Always use the computational region of the raster elevation
+ cls.use_temp_region()
+ cls.runModule('g.region', raster=cls.elevation)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region"""
+ cls.del_temp_region()
+
+ def tearDown(self):
+ """Remove the outputs created from the grow distance module
+
+ This is executed after each test run.
+ """
+ self.runModule('g.remove', flags='f', type='raster',
+ name=self.distance)
+
+ def test_grow(self):
+ """Test to see if the outputs are created"""
+ # run the grow distance module
+ self.assertModule('r.grow.distance', input=self.lakes,
+ distance=self.distance)
+ # check to see if distance output is in mapset
+ self.assertRasterExists(self.distance,
+ msg='distance output was not created')
+ self.assertRasterMinMax(self.distance, 0, 5322,
+ msg='distance output not in range')
+
+
+if __name__ == '__main__':
+ test()
More information about the grass-commit
mailing list