From cd81c787139804af6420267aae8d3cc4ae287677 Mon Sep 17 00:00:00 2001 From: Thomas Zuberbuehler Date: Thu, 31 Aug 2023 21:19:43 -0300 Subject: [PATCH] bugfix aputil.tcursor --- test/tcursor_test.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/tcursor_test.py b/test/tcursor_test.py index 371d37d..45b224f 100644 --- a/test/tcursor_test.py +++ b/test/tcursor_test.py @@ -21,7 +21,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import arcpy +import arcpy, arcpy.da, arcpy.management import unittest import tempfile @@ -45,14 +45,14 @@ def setUp(self): self.temp = tempfile.TemporaryDirectory() self.geodatabase = arcpy.management.CreateFileGDB(self.temp.name, "test.gdb") - self.feature_class = arcpy.management.CreateFeatureclass(self.geodatabase, "Test") + self.feature_class = arcpy.management.CreateFeatureclass(self.geodatabase, "Test", geometry_type="Point") for field in TCursorTest.FIELDS: arcpy.management.AddField(self.feature_class, field, "TEXT") - with arcpy.da.InsertCursor(self.feature_class, TCursorTest.FIELDS) as cursor: + with arcpy.da.InsertCursor(self.feature_class, ["SHAPE@", *TCursorTest.FIELDS]) as cursor: for index in range(0, 25): - cursor.insertRow((str(index), "Test", None, "Test {}".format(index))) + cursor.insertRow((arcpy.Point(1, 2), str(index), "Test", None, "Test {}".format(index))) def tearDown(self): @@ -80,6 +80,15 @@ def test(self): self.assertIsNone(row.Column3) + with arcpy.da.SearchCursor(self.feature_class, ["SHAPE@XY", "SHAPE@", "SHAPE@WKT"]) as cursor: + + first = next(tcursor(cursor)) + + self.assertIsNotNone(first.SHAPE_) + self.assertAlmostEqual(first.SHAPE_XY[0], 1, places=3) + self.assertAlmostEqual(first.SHAPE_XY[1], 2, places=3) + self.assertIsInstance(first.SHAPE_WKT, str) + def run_tests():