[GRASS-SVN] r62135 - grass/trunk/lib/python/pygrass/vector/testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 30 01:48:22 PDT 2014


Author: zarch
Date: 2014-09-30 01:48:22 -0700 (Tue, 30 Sep 2014)
New Revision: 62135

Added:
   grass/trunk/lib/python/pygrass/vector/testsuite/test_vector.py
Log:
pygrass: Add test on __getitem__ method in VectorTopo class

Added: grass/trunk/lib/python/pygrass/vector/testsuite/test_vector.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/testsuite/test_vector.py	                        (rev 0)
+++ grass/trunk/lib/python/pygrass/vector/testsuite/test_vector.py	2014-09-30 08:48:22 UTC (rev 62135)
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Wed Jun 18 17:21:42 2014
+
+ at author: pietro
+"""
+from grass.gunittest import TestCase, test
+
+from grass.pygrass.vector import VectorTopo
+
+
+class VectorTopoTestCase(TestCase):
+
+    vname = "points_of_interest"
+
+    def test_getitem_slice(self):
+        """Test that getitem handle correctly the slice starting from 1"""
+        vcoords = ((646341.7386813264, 218873.73056803632),
+                   (637772.0990144431, 218842.80557760992))
+        with VectorTopo(self.vname, mode="r") as vect:
+            coords = tuple([pnt.coords() for pnt in vect[:3]])
+            self.assertTupleEqual(vcoords, coords)
+            coords = tuple([pnt.coords() for pnt in vect[1:3]])
+            self.assertTupleEqual(vcoords, coords)
+
+    def test_getitem_raise(self):
+        """Test that getitem raise a value error if the key is not
+        an integer or a slice"""
+        with VectorTopo(self.vname, mode="r") as vect:
+            with self.assertRaises(ValueError):
+                vect['value']
+
+
+if __name__ == '__main__':
+    test()


Property changes on: grass/trunk/lib/python/pygrass/vector/testsuite/test_vector.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list