Skip to content
Browse files
Add some comments to provider test suite
  • Loading branch information
m-kuhn committed May 23, 2015
1 parent c1b520f commit 40e2845d490b160cd66ce02852892d7f77e7e5ad
Showing with 11 additions and 3 deletions.
  1. +11 −3 tests/src/python/
@@ -13,10 +13,18 @@
__revision__ = '$Format:%H$'

from qgis.core import QgsRectangle, QgsFeatureRequest, QgsGeometry, NULL
from utilities import TestCase

class ProviderTestCase(object):
This is a collection of tests for vector data providers and kept generic.
To make use of it, subclass it and set self.provider to a provider you want to test.
Make sure that your provider uses the default dataset by converting one of the provided datasets from the folder
tests/testdata/provider to a dataset your provider is able to handle.
To test expression compilation, add the methods `enableCompiler()` and `disableCompiler()` to your subclass.
If these methods are present, the tests will ensure that the result of server side and client side expression
evaluation are equal.
def runGetFeatureTests(self, provider):
assert len([f for f in provider.getFeatures()]) == 5
assert len([f for f in provider.getFeatures(QgsFeatureRequest().setFilterExpression('name IS NOT NULL'))]) == 4
@@ -62,7 +70,7 @@ def testMaxValue(self):

def testExtent(self):
reference = QgsGeometry.fromRect(
QgsRectangle(-71.1230000000000047, 66.3299999999999983, -65.3199999999999932, 78.2999999999999972))
QgsRectangle(-71.123, 66.33, -65.32, 78.3))
provider_extent = QgsGeometry.fromRect(self.provider.extent())

assert, reference.asPolygon(), 0.000001)

0 comments on commit 40e2845

Please sign in to comment.