|
33 | 33 | from qgis.testing import start_app, unittest |
34 | 34 |
|
35 | 35 | from processing.core.ProcessingConfig import ProcessingConfig |
36 | | -from processing.tests.TestData import testDataPath, points |
| 36 | +from processing.tests.TestData import testDataPath, points, invalid_geometries |
37 | 37 | from processing.tools import vector |
38 | 38 |
|
39 | 39 | testDataPath = os.path.join(os.path.dirname(__file__), 'testdata') |
@@ -98,7 +98,21 @@ def testFeatures(self): |
98 | 98 | features = vector.features(test_layer, QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry)) |
99 | 99 | self.assertEqual(set([f.id() for f in features]), set([2, 4, 6])) |
100 | 100 |
|
| 101 | + #test exception is raised when filtering invalid geoms |
| 102 | + test_layer_invalid_geoms = QgsVectorLayer(invalid_geometries(), 'test', 'ogr') |
| 103 | + |
| 104 | + previous_value_invalid_geoms = ProcessingConfig.getSetting(ProcessingConfig.FILTER_INVALID_GEOMETRIES) |
| 105 | + ProcessingConfig.setSettingValue(ProcessingConfig.FILTER_INVALID_GEOMETRIES, 2) |
| 106 | + try: |
| 107 | + features = vector.features(test_layer_invalid_geoms) |
| 108 | + features = [f for f in features] |
| 109 | + self.fail() |
| 110 | + except GeoAlgorithmExecutionException: |
| 111 | + pass |
| 112 | + |
| 113 | + ProcessingConfig.setSettingValue(ProcessingConfig.FILTER_INVALID_GEOMETRIES, previous_value_invalid_geoms) |
101 | 114 | ProcessingConfig.setSettingValue(ProcessingConfig.USE_SELECTED, previous_value) |
| 115 | + |
102 | 116 |
|
103 | 117 | def testValues(self): |
104 | 118 | ProcessingConfig.initialize() |
|
0 commit comments