Skip to content

Commit

Permalink
[Tests] Fix deprecated QgsVectorLayer::setDataSource usage
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Apr 21, 2021
1 parent b31e01b commit 2dd3d9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/src/python/test_provider_shapefile.py
Expand Up @@ -618,6 +618,7 @@ def testRepackAtFirstSave(self):
def testOpenWithFilter(self):
file_path = os.path.join(TEST_DATA_DIR, 'provider', 'shapefile.shp')
uri = '{}|layerid=0|subset="name" = \'Apple\''.format(file_path)
options = QgsDataProvider.ProviderOptions()
# ensure that no longer required ogr SQL layers are correctly cleaned up
# we need to run this twice for the incorrect cleanup asserts to trip,
# since they are triggered only when fetching an existing layer from the ogr
Expand All @@ -629,7 +630,7 @@ def testOpenWithFilter(self):
f = next(vl.getFeatures())
self.assertEqual(f['name'], 'Apple')
# force close of data provider
vl.setDataSource('', 'test', 'ogr')
vl.setDataSource('', 'test', 'ogr', options)

def testEncoding(self):
file_path = os.path.join(TEST_DATA_DIR, 'shapefile', 'iso-8859-1.shp')
Expand Down
5 changes: 3 additions & 2 deletions tests/src/python/test_qgsprojectbadlayers.py
Expand Up @@ -219,8 +219,9 @@ def _check_relations():
_check_relations()

# Changing data source, relations should be restored:
point_a.setDataSource(point_a_source, 'point_a', 'ogr')
point_b.setDataSource(point_b_source, 'point_b', 'ogr')
options = QgsDataProvider.ProviderOptions()
point_a.setDataSource(point_a_source, 'point_a', 'ogr', options)
point_b.setDataSource(point_b_source, 'point_b', 'ogr', options)
self.assertTrue(point_a.isValid())
self.assertTrue(point_b.isValid())

Expand Down

0 comments on commit 2dd3d9b

Please sign in to comment.