Skip to content
Permalink
Browse files

Add a test for python provider using both direct iterator and iterato…

…r from layer
  • Loading branch information
nyalldawson committed Feb 8, 2021
1 parent 4984de7 commit e509e653030396c95086baaae69c2cc7148e4687
Showing with 12 additions and 0 deletions.
  1. +12 −0 tests/src/python/test_provider_python.py
@@ -402,6 +402,18 @@ def tesRegisterSameProviderTwice(self):
metadata = QgsProviderMetadata(PyProvider.providerKey(), PyProvider.description(), PyProvider.createProvider)
self.assertFalse(r.registerProvider(metadata))

def testGetFeaturesFromProvider(self):
"""
Regardless of whether we get features direct from the provider or through the layer, the
result should be the same...
"""
layer = self.createLayer()
provider_features = {f.id(): f.attributes() for f in layer.dataProvider().getFeatures()}
self.assertTrue(provider_features)
layer_features = {f.id(): f.attributes() for f in layer.dataProvider().getFeatures()}
self.assertTrue(layer_features)
self.assertEqual(provider_features, layer_features)


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

0 comments on commit e509e65

Please sign in to comment.