Skip to content

Commit

Permalink
Correct autodetection of vsizip based shapefiles depends on GDAL 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 12, 2020
1 parent 54eba4a commit 50bdd36
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/src/python/test_provider_shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import osgeo.ogr
import sys

from osgeo import gdal
from qgis.core import (
QgsApplication,
QgsSettings,
Expand Down Expand Up @@ -662,11 +663,13 @@ def testEncoding(self):
self.assertEqual(vl.dataProvider().encoding(), 'windows-1252')
self.assertEqual(next(vl.getFeatures())[1], 'äöü')

file_path = os.path.join(TEST_DATA_DIR, 'shapefile', 'windows-1252.zip')
vl = QgsVectorLayer('/vsizip/{}'.format(file_path))
self.assertTrue(vl.isValid())
self.assertEqual(vl.dataProvider().encoding(), 'windows-1252')
self.assertEqual(next(vl.getFeatures())[1], 'äöü')
if int(gdal.VersionInfo('VERSION_NUM')) >= GDAL_COMPUTE_VERSION(3, 1, 0):
# correct autodetection of vsizip based shapefiles depends on GDAL 3.1
file_path = os.path.join(TEST_DATA_DIR, 'shapefile', 'windows-1252.zip')
vl = QgsVectorLayer('/vsizip/{}'.format(file_path))
self.assertTrue(vl.isValid())
self.assertEqual(vl.dataProvider().encoding(), 'windows-1252')
self.assertEqual(next(vl.getFeatures())[1], 'äöü')

file_path = os.path.join(TEST_DATA_DIR, 'shapefile', 'system_encoding.shp')
vl = QgsVectorLayer(file_path)
Expand Down

0 comments on commit 50bdd36

Please sign in to comment.