Skip to content

Commit

Permalink
Handle null values in processing attribute tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 13, 2017
1 parent 94fa450 commit 6dbdbea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/testing/__init__.py
Expand Up @@ -31,7 +31,7 @@
import functools

from qgis.PyQt.QtCore import QVariant
from qgis.core import QgsApplication, QgsFeatureRequest
from qgis.core import QgsApplication, QgsFeatureRequest, NULL
import unittest

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

# Round field (only numeric so it works with __all__)
if 'precision' in cmp and field_expected.type() in [QVariant.Int, QVariant.Double, QVariant.LongLong]:
attr_expected = round(attr_expected, cmp['precision'])
attr_result = round(attr_result, cmp['precision'])
if not attr_expected == NULL:
attr_expected = round(attr_expected, cmp['precision'])
if not attr_result == NULL:
attr_result = round(attr_result, cmp['precision'])

if use_asserts:
_TestCase.assertEqual(
Expand Down

0 comments on commit 6dbdbea

Please sign in to comment.