[Bf-blender-cvs] [8c22a974d63] master: Tests: Compare vectors with epsilon

Sergey Sharybin noreply at git.blender.org
Fri Apr 7 18:28:43 CEST 2017


Commit: 8c22a974d63db2b3182a5b7855c5794bc9cb111f
Author: Sergey Sharybin
Date:   Fri Apr 7 18:26:39 2017 +0200
Branches: master
https://developer.blender.org/rB8c22a974d63db2b3182a5b7855c5794bc9cb111f

Tests: Compare vectors with epsilon

SOlves the test false-positively failing in 32 bit environment.

===================================================================

M	tests/python/bl_pyapi_mathutils.py

===================================================================

diff --git a/tests/python/bl_pyapi_mathutils.py b/tests/python/bl_pyapi_mathutils.py
index 7761b6cb7b1..9ca0376192a 100644
--- a/tests/python/bl_pyapi_mathutils.py
+++ b/tests/python/bl_pyapi_mathutils.py
@@ -260,6 +260,11 @@ class KDTreeTesting(unittest.TestCase):
         k.balance()
         return k
 
+    def assertAlmostEqualVector(self, first, second, places=7, msg=None, delta=None):
+        self.assertAlmostEqual(first[0], second[0], places=places, msg=msg, delta=delta)
+        self.assertAlmostEqual(first[1], second[1], places=places, msg=msg, delta=delta)
+        self.assertAlmostEqual(first[2], second[2], places=places, msg=msg, delta=delta)
+
     def test_kdtree_single(self):
         co = (0,) * 3
         index = 2
@@ -360,12 +365,12 @@ class KDTreeTesting(unittest.TestCase):
                     ret_regular = k_odd.find(co)
                     self.assertEqual(ret_regular[1] % 2, 1)
                     ret_filter = k_all.find(co, lambda i: (i % 2) == 1)
-                    self.assertEqual(ret_regular, ret_filter)
+                    self.assertAlmostEqualVector(ret_regular, ret_filter)
 
                     ret_regular = k_evn.find(co)
                     self.assertEqual(ret_regular[1] % 2, 0)
                     ret_filter = k_all.find(co, lambda i: (i % 2) == 0)
-                    self.assertEqual(ret_regular, ret_filter)
+                    self.assertAlmostEqualVector(ret_regular, ret_filter)
 
 
         # filter out all values (search odd tree for even values and the reverse)




More information about the Bf-blender-cvs mailing list