From 136c5a4bc2556624ff9379fb362765ea9e4f9f37 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Mon, 15 Jun 2020 19:38:13 +0300 Subject: [PATCH] perform rounding either if field type is numeric or if value was casted to the number --- python/testing/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/testing/__init__.py b/python/testing/__init__.py index 436c15f995d2..10c86470aa35 100644 --- a/python/testing/__init__.py +++ b/python/testing/__init__.py @@ -269,19 +269,22 @@ def checkAttributesEqual(self, feat0, feat1, fields_expected, use_asserts, compa field_result = [fld for fld in fields_expected.toList() if fld.name() == field_expected.name()][0] # Cast field to a given type + isNumber = False if 'cast' in cmp: if cmp['cast'] == 'int': attr_expected = int(attr_expected) if attr_expected else None attr_result = int(attr_result) if attr_result else None + isNumber = True if cmp['cast'] == 'float': attr_expected = float(attr_expected) if attr_expected else None attr_result = float(attr_result) if attr_result else None + isNumber = True if cmp['cast'] == 'str': attr_expected = str(attr_expected) if attr_expected else None attr_result = str(attr_result) if attr_result else None # Round field (only numeric so it works with __all__) - if 'precision' in cmp and field_expected.type() in [QVariant.Int, QVariant.Double, QVariant.LongLong]: + if 'precision' in cmp and (field_expected.type() in [QVariant.Int, QVariant.Double, QVariant.LongLong] or isNumber): if not attr_expected == NULL: attr_expected = round(attr_expected, cmp['precision']) if not attr_result == NULL: