Skip to content
Permalink
Browse files
test_provider_ogr_gpkg.py: fix crash by keeping a reference to the fe…
…ature object so that the geometry object isn't invalid
  • Loading branch information
rouault committed Apr 25, 2016
1 parent b4698ad commit 847e41619c8ab61b5d2b252b975028b649345132
Showing with 6 additions and 4 deletions.
  1. +6 −4 tests/src/python/test_provider_ogr_gpkg.py
@@ -56,10 +56,11 @@ def testSingleToMultiPolygonPromotion(self):
f = QgsFeature()
f.setGeometry(QgsGeometry.fromWkt('POLYGON ((0 0,0 1,1 1,0 0))'))
vl.dataProvider().addFeatures([f])
got = [f.geometry() for f in vl.getFeatures()][0]
got = [f for f in vl.getFeatures()][0]
got_geom = got.geometry()
reference = QgsGeometry.fromWkt('MultiPolygon (((0 0, 0 1, 1 1, 0 0)))')
# The geometries must be binarily identical
self.assertEqual(got.asWkb(), reference.asWkb(), 'Expected {}, got {}'.format(reference.exportToWkt(), got.exportToWkt()))
self.assertEqual(got_geom.asWkb(), reference.asWkb(), 'Expected {}, got {}'.format(reference.exportToWkt(), got_geom.exportToWkt()))

@unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0))
def testCurveGeometryType(self):
@@ -74,10 +75,11 @@ def testCurveGeometryType(self):
f = QgsFeature()
f.setGeometry(QgsGeometry.fromWkt('POLYGON ((0 0,0 1,1 1,0 0))'))
vl.dataProvider().addFeatures([f])
got = [f.geometry() for f in vl.getFeatures()][0]
got = [f for f in vl.getFeatures()][0]
got_geom = got.geometry()
reference = QgsGeometry.fromWkt('CurvePolygon (((0 0, 0 1, 1 1, 0 0)))')
# The geometries must be binarily identical
self.assertEqual(got.asWkb(), reference.asWkb(), 'Expected {}, got {}'.format(reference.exportToWkt(), got.exportToWkt()))
self.assertEqual(got_geom.asWkb(), reference.asWkb(), 'Expected {}, got {}'.format(reference.exportToWkt(), got_geom.exportToWkt()))

def testFidSupport(self):

0 comments on commit 847e416

Please sign in to comment.