Skip to content

Commit

Permalink
bugfix aputil.tcursor
Browse files Browse the repository at this point in the history
  • Loading branch information
moosetraveller committed Sep 1, 2023
1 parent abbd3df commit cd81c78
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions test/tcursor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):

Expand Down Expand Up @@ -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():

Expand Down

0 comments on commit cd81c78

Please sign in to comment.