Skip to content

Commit 6dbdbea

Browse files
committedNov 13, 2017
Handle null values in processing attribute tests
1 parent 94fa450 commit 6dbdbea

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎python/testing/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import functools
3232

3333
from qgis.PyQt.QtCore import QVariant
34-
from qgis.core import QgsApplication, QgsFeatureRequest
34+
from qgis.core import QgsApplication, QgsFeatureRequest, NULL
3535
import unittest
3636

3737
# Get a backup, we will patch this one later
@@ -170,8 +170,10 @@ def sort_by_pk_or_fid(f):
170170

171171
# Round field (only numeric so it works with __all__)
172172
if 'precision' in cmp and field_expected.type() in [QVariant.Int, QVariant.Double, QVariant.LongLong]:
173-
attr_expected = round(attr_expected, cmp['precision'])
174-
attr_result = round(attr_result, cmp['precision'])
173+
if not attr_expected == NULL:
174+
attr_expected = round(attr_expected, cmp['precision'])
175+
if not attr_result == NULL:
176+
attr_result = round(attr_result, cmp['precision'])
175177

176178
if use_asserts:
177179
_TestCase.assertEqual(

0 commit comments

Comments
 (0)
Please sign in to comment.