Skip to content

Commit d1eabe1

Browse files
committed
Make compiled tests more stable
we do not want to ignore AttributeErrors for those
1 parent dbe4186 commit d1eabe1

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

tests/src/python/providertestbase.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def uncompiledFilters(self):
5252
cannot be compiled """
5353
return set()
5454

55+
def enableCompiler(self):
56+
"""By default there is no expression compiling available, needs to be overridden in subclass"""
57+
print('Provider does not support compiling')
58+
return False
59+
5560
def partiallyCompiledFilters(self):
5661
""" Individual derived provider tests should override this to return a list of expressions which
5762
should be partially compiled """
@@ -141,14 +146,11 @@ def testGetFeaturesUncompiled(self):
141146
self.runPolyGetFeatureTests(self.poly_provider)
142147

143148
def testGetFeaturesExp(self):
144-
try:
145-
self.enableCompiler()
149+
if self.enableCompiler():
146150
self.compiled = True
147151
self.runGetFeatureTests(self.source)
148152
if hasattr(self, 'poly_provider'):
149153
self.runPolyGetFeatureTests(self.poly_provider)
150-
except AttributeError:
151-
print('Provider does not support compiling')
152154

153155
def testSubsetString(self):
154156
if not self.source.supportsSubsetString():
@@ -232,11 +234,8 @@ def testOrderBy(self):
232234
self.runOrderByTests()
233235

234236
def testOrderByCompiled(self):
235-
try:
236-
self.enableCompiler()
237+
if self.enableCompiler():
237238
self.runOrderByTests()
238-
except AttributeError:
239-
print('Provider does not support compiling')
240239

241240
def runOrderByTests(self):
242241
FeatureSourceTestCase.runOrderByTests(self)

tests/src/python/test_provider_db2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def getSubsetString(self):
5858

5959
def enableCompiler(self):
6060
QgsSettings().setValue('/qgis/compileExpressions', True)
61+
return True
6162

6263
def disableCompiler(self):
6364
QgsSettings().setValue('/qgis/compileExpressions', False)

tests/src/python/test_provider_mssql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def tearDownClass(cls):
5252

5353
def enableCompiler(self):
5454
QgsSettings().setValue('/qgis/compileExpressions', True)
55+
return True
5556

5657
def disableCompiler(self):
5758
QgsSettings().setValue('/qgis/compileExpressions', False)

tests/src/python/test_provider_oracle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def getEditableLayer(self):
8585

8686
def enableCompiler(self):
8787
QgsSettings().setValue('/qgis/compileExpressions', True)
88+
return True
8889

8990
def disableCompiler(self):
9091
QgsSettings().setValue('/qgis/compileExpressions', False)

tests/src/python/test_provider_postgres.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def getEditableLayer(self):
104104

105105
def enableCompiler(self):
106106
QgsSettings().setValue('/qgis/compileExpressions', True)
107+
return True
107108

108109
def disableCompiler(self):
109110
QgsSettings().setValue('/qgis/compileExpressions', False)
@@ -1125,6 +1126,7 @@ def tearDownClass(cls):
11251126

11261127
def enableCompiler(self):
11271128
QgsSettings().setValue('/qgis/compileExpressions', True)
1129+
return True
11281130

11291131
def disableCompiler(self):
11301132
QgsSettings().setValue('/qgis/compileExpressions', False)

tests/src/python/test_provider_shapefile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def getEditableLayer(self):
9393

9494
def enableCompiler(self):
9595
QgsSettings().setValue('/qgis/compileExpressions', True)
96+
return True
9697

9798
def disableCompiler(self):
9899
QgsSettings().setValue('/qgis/compileExpressions', False)

tests/src/python/test_provider_spatialite.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ def tearDown(self):
260260

261261
def enableCompiler(self):
262262
QgsSettings().setValue('/qgis/compileExpressions', True)
263+
return True
263264

264265
def disableCompiler(self):
265266
QgsSettings().setValue('/qgis/compileExpressions', False)

0 commit comments

Comments
 (0)