Skip to content
Permalink
Browse files

tests: replace wrong uses of unittest.skip() by unittest.skipIf()

  • Loading branch information
rouault committed Sep 29, 2020
1 parent a0ec119 commit 9083c562416490a9681233bf04307dad2f568853
@@ -526,7 +526,7 @@ def testBinaryField(self):
self.assertIsInstance(features[2]['DATA'], QByteArray)
self.assertEqual(hashlib.md5(features[2]['DATA'].data()).hexdigest(), '4b952b80e4288ca5111be2f6dd5d6809')

@unittest.skip(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 4, 0))
@unittest.skipIf(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 4, 0), "GDAL 2.4 required")
def testStringListField(self):
source = os.path.join(TEST_DATA_DIR, 'stringlist.gml')
vl = QgsVectorLayer(source)
@@ -730,7 +730,7 @@ def testMixOfFilterExpressionAndSubsetStringWhenFilterExpressionCompilationFails

self.assertCountEqual([f.attributes() for f in vl.getFeatures(request)], [['rectangle', '1']])

@unittest.skip(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(3, 2, 0))
@unittest.skipIf(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(3, 2, 0), "GDAL 3.2 required")
def testFieldAliases(self):
"""
Test that field aliases are taken from OGR where available (requires GDAL 3.2 or later)
@@ -740,9 +740,17 @@ def testFieldAliases(self):
self.assertTrue(vl.isValid())

fields = vl.fields()
self.assertEqual([f.name() for f in fields], ['OBJECTID', 'text', 'short_int', 'long_int', 'float', 'double', 'date', 'blob', 'guid', 'raster', 'SHAPE_Length', 'SHAPE_Area'])
self.assertEqual([f.alias() for f in fields],
['', 'My Text Field', 'My Short Int Field', 'My Long Int Field', 'My Float Field', 'My Double Field', 'My Date Field', 'My Blob Field', 'My GUID field', 'My Raster Field', '', ''])

# proprietary FileGDB driver doesn't have the raster column
if 'raster' not in set(f.name() for f in fields):
expected_fieldnames = ['OBJECTID', 'text', 'short_int', 'long_int', 'float', 'double', 'date', 'blob', 'guid', 'SHAPE_Length', 'SHAPE_Area']
expected_alias = ['', 'My Text Field', 'My Short Int Field', 'My Long Int Field', 'My Float Field', 'My Double Field', 'My Date Field', 'My Blob Field', 'My GUID field', '', '']
else:
expected_fieldnames = ['OBJECTID', 'text', 'short_int', 'long_int', 'float', 'double', 'date', 'blob', 'guid', 'raster', 'SHAPE_Length', 'SHAPE_Area']
expected_alias = ['', 'My Text Field', 'My Short Int Field', 'My Long Int Field', 'My Float Field', 'My Double Field', 'My Date Field', 'My Blob Field', 'My GUID field', 'My Raster Field', '', '']

self.assertEqual([f.name() for f in fields], expected_fieldnames)
self.assertEqual([f.alias() for f in fields], expected_alias)


if __name__ == '__main__':
@@ -389,7 +389,7 @@ def testBug15351_commit_closeProvider_closeIter(self):
def testBug15351_commit_closeIter_closeProvider(self):
self.internalTestBug15351('commit_closeIter_closeProvider')

@unittest.skip(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 1, 2))
@unittest.skipIf(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 1, 2), 'GDAL 2.1.2 required')
def testGeopackageExtentUpdate(self):
''' test https://github.com/qgis/QGIS/issues/23209 '''
tmpfile = os.path.join(self.basetestpath, 'testGeopackageExtentUpdate.gpkg')
@@ -1045,13 +1045,14 @@ def testDropZ(self):
f = next(created_layer.getFeatures(QgsFeatureRequest()))
self.assertEqual(f.geometry().asWkt(), 'Point (10 10)')

@unittest.skip(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 4, 0))
@unittest.skipIf(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(2, 4, 0), "GDAL 2.4.0 required")
def testWriteWithStringListField(self):
"""
Test writing with a string list field
:return:
"""
tmpfile = os.path.join(self.basetestpath, 'newstringlistfield.gml')
basetestpath = tempfile.mkdtemp()
tmpfile = os.path.join(basetestpath, 'newstringlistfield.gml')
ds = ogr.GetDriverByName('GML').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbPoint)
lyr.CreateField(ogr.FieldDefn('strfield', ogr.OFTString))

0 comments on commit 9083c56

Please sign in to comment.
You can’t perform that action at this time.