Skip to content
Permalink
Browse files

Followup c9b8ddc, add unit test

  • Loading branch information
nyalldawson committed Nov 20, 2017
1 parent 6d0f2af commit 95cf299099ce289f796bd4f5b61533d959213423
Showing with 16 additions and 0 deletions.
  1. +16 −0 tests/src/python/test_provider_shapefile.py
@@ -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.
You can’t perform that action at this time.