[GRASS-SVN] r66060 - in grass/trunk/lib/python/pygrass: . gis vector/testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 29 11:19:00 PDT 2015


Author: huhabla
Date: 2015-08-29 11:19:00 -0700 (Sat, 29 Aug 2015)
New Revision: 66060

Modified:
   grass/trunk/lib/python/pygrass/gis/region.py
   grass/trunk/lib/python/pygrass/utils.py
   grass/trunk/lib/python/pygrass/vector/testsuite/test_geometry.py
   grass/trunk/lib/python/pygrass/vector/testsuite/test_vector.py
   grass/trunk/lib/python/pygrass/vector/testsuite/test_vector3d.py
Log:
pygrass library: Make use of the gunittst framework methods for module calls. The region class can now set the computational raster region of a process.


Modified: grass/trunk/lib/python/pygrass/gis/region.py
===================================================================
--- grass/trunk/lib/python/pygrass/gis/region.py	2015-08-29 17:21:36 UTC (rev 66059)
+++ grass/trunk/lib/python/pygrass/gis/region.py	2015-08-29 18:19:00 UTC (rev 66060)
@@ -305,7 +305,8 @@
         ..
         """
         attrs = ['north', 'south', 'west', 'east', 'top', 'bottom',
-                 'nsres', 'ewres', 'tbres']
+                 'nsres', 'ewres', 'tbres', 'rows', 'cols', 'cells',
+                 'zone', 'proj']
         for attr in attrs:
             if getattr(self, attr) != getattr(reg, attr):
                 return False
@@ -422,6 +423,17 @@
             libraster.Rast_get_cellhd(raster_name, mapset,
                                       self.byref())
 
+    def set_raster_region(self):
+        """Set the computational region (window) for all raster maps in the current process.
+           
+           Attention: All raster objects must be closed or the
+                      process will be terminated.
+                      
+           The Raster library C function Rast_set_window() is called.
+        
+        """
+        libraster.Rast_set_window(self.byref())
+
     def get_current(self):
         """Get the current working region of this process
            and store it into this Region object

Modified: grass/trunk/lib/python/pygrass/utils.py
===================================================================
--- grass/trunk/lib/python/pygrass/utils.py	2015-08-29 17:21:36 UTC (rev 66059)
+++ grass/trunk/lib/python/pygrass/utils.py	2015-08-29 18:19:00 UTC (rev 66060)
@@ -419,6 +419,11 @@
         vect.comment = 'This is a comment'
 
         vect.table.conn.commit()
+        
+        vect.organization = "Thuenen Institut"
+        vect.person = "Soeren Gebbert"
+        vect.title = "Test dataset"
+        vect.comment = "This is a comment"
         vect.close()
 
 def create_test_stream_network_map(map_name="streams"):

Modified: grass/trunk/lib/python/pygrass/vector/testsuite/test_geometry.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/testsuite/test_geometry.py	2015-08-29 17:21:36 UTC (rev 66059)
+++ grass/trunk/lib/python/pygrass/vector/testsuite/test_geometry.py	2015-08-29 18:19:00 UTC (rev 66060)
@@ -121,10 +121,8 @@
             cls.c_mapinfo = None
 
         """Remove the generated vector map, if exist"""
-        from grass.pygrass.utils import get_mapset_vector
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
     def test_len(self):
         """Test __len__ magic method"""
@@ -214,10 +212,8 @@
             cls.c_mapinfo = None
 
         """Remove the generated vector map, if exist"""
-        from grass.pygrass.utils import get_mapset_vector
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
     def test_init(self):
         """Test Node __init__"""
@@ -270,10 +266,8 @@
             cls.c_mapinfo = None
 
         """Remove the generated vector map, if exist"""
-        from grass.pygrass.utils import get_mapset_vector
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
     def test_init(self):
         """Test area __init__ and basic functions"""

Modified: grass/trunk/lib/python/pygrass/vector/testsuite/test_vector.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/testsuite/test_vector.py	2015-08-29 17:21:36 UTC (rev 66059)
+++ grass/trunk/lib/python/pygrass/vector/testsuite/test_vector.py	2015-08-29 18:19:00 UTC (rev 66060)
@@ -30,11 +30,10 @@
     def tearDownClass(cls):
         if cls.vect.is_open():
             cls.vect.close()
+
         """Remove the generated vector map, if exist"""
-        from grass.pygrass.utils import get_mapset_vector
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
     def test_getitem_slice(self):
         """Test that getitem handle correctly the slice starting from 1"""

Modified: grass/trunk/lib/python/pygrass/vector/testsuite/test_vector3d.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/testsuite/test_vector3d.py	2015-08-29 17:21:36 UTC (rev 66059)
+++ grass/trunk/lib/python/pygrass/vector/testsuite/test_vector3d.py	2015-08-29 18:19:00 UTC (rev 66060)
@@ -60,9 +60,8 @@
     @classmethod
     def tearDownClass(cls):
         """Remove the generated vector map, if exist"""
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
 
 if __name__ == '__main__':



More information about the grass-commit mailing list