Skip to content

Commit

Permalink
Followup c9b8ddc, add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 20, 2017
1 parent 6d0f2af commit 95cf299
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/src/python/test_provider_shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,22 @@ def testRepackAtFirstSave(self):
self.assertTrue(ds.GetLayer(0).GetFeatureCount(), original_feature_count - 1)
ds = None

def testOpenWithFilter(self):
file_path = os.path.join(TEST_DATA_DIR, 'provider')
uri = '{}|layerid=0|subset="name" = \'Apple\''.format(file_path)
# 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
# connection pool
for i in range(2):
vl = QgsVectorLayer(uri)
self.assertTrue(vl.isValid())
self.assertEqual(vl.featureCount(), 1)
f = next(vl.getFeatures())
self.assertEqual(f['name'], 'Apple')
# force close of data provider
vl.setDataSource('', 'test', 'ogr')


if __name__ == '__main__':
unittest.main()

0 comments on commit 95cf299

Please sign in to comment.