Skip to content

Commit

Permalink
test_provider_ogr_gpkg.py: compare geometry by wkb, and use @unittest…
Browse files Browse the repository at this point in the history
….expectedFailure decorator
  • Loading branch information
rouault committed Apr 25, 2016
1 parent aa2014d commit b4698ad
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tests/src/python/test_provider_ogr_gpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ def tearDownClass(cls):
"""Run after all tests"""
shutil.rmtree(cls.basetestpath, True)

@unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(1, 11, 0))
def testSingleToMultiPolygonPromotion(self):

version_num = int(gdal.VersionInfo('VERSION_NUM'))
if version_num < GDAL_COMPUTE_VERSION(1, 11, 0):
return

tmpfile = os.path.join(self.basetestpath, 'testSingleToMultiPolygonPromotion.gpkg')
ds = ogr.GetDriverByName('GPKG').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbMultiPolygon)
Expand All @@ -59,15 +56,14 @@ 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().exportToWkt(0) for f in vl.getFeatures()][0]
self.assertEqual(got, 'MultiPolygon (((0 0, 0 1, 1 1, 0 0)))')
got = [f.geometry() for f in vl.getFeatures()][0]
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()))

@unittest.expectedFailure(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 0, 0))
def testCurveGeometryType(self):

version_num = int(gdal.VersionInfo('VERSION_NUM'))
if version_num < GDAL_COMPUTE_VERSION(2, 0, 0):
return

tmpfile = os.path.join(self.basetestpath, 'testCurveGeometryType.gpkg')
ds = ogr.GetDriverByName('GPKG').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbCurvePolygon)
Expand All @@ -78,11 +74,16 @@ 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().exportToWkt(0) for f in vl.getFeatures()][0]
self.assertEqual(got, 'CurvePolygon ((0 0, 0 1, 1 1, 0 0))')
got = [f.geometry() for f in vl.getFeatures()][0]
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()))

def testFidSupport(self):

# We do not use @unittest.expectedFailure since the test might actually succeed
# on Linux 64bit with GDAL 1.11, where "long" is 64 bit...
# GDAL 2.0 is guaranteed to properly support it on all platforms
version_num = int(gdal.VersionInfo('VERSION_NUM'))
if version_num < GDAL_COMPUTE_VERSION(2, 0, 0):
return
Expand Down

0 comments on commit b4698ad

Please sign in to comment.