From 6dbdbead0cc0ad5b255add55be5544f2c44a780d Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 14 Nov 2017 07:14:46 +1000 Subject: [PATCH] Handle null values in processing attribute tests --- python/testing/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/testing/__init__.py b/python/testing/__init__.py index 4dbae30911f..83bf2ce78ee 100644 --- a/python/testing/__init__.py +++ b/python/testing/__init__.py @@ -31,7 +31,7 @@ import difflib 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 @@ -170,8 +170,10 @@ class TestCase(_TestCase): # 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(