Fixed issue with float vectors assertion during tests

`sequence.feature` - Added `[:]` to make errors more readable values in errors (for example, (0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 1.0) instead of `<bpy_float[4], Object.color>`

`test_feature.py` - fixed `FAILED test/bim/test_feature.py::test_animate_the_consumption_of_a_wall - AssertionError: Value is <bpy_float[4], Object.color>`
Test was failing because of float garbage in object.color (the comparison was (0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 1.0) <> [0.2, 0.2, 0.2, 1] )

After that fix all tests now are passed 🥲
This commit is contained in:
Andrej730
2023-02-20 18:11:08 +05:00
parent 0e1689c2d9
commit 1dfabe2591
2 changed files with 25 additions and 17 deletions
+9 -1
View File
@@ -51,6 +51,10 @@ def replace_variables(value):
def is_x(number, x):
return abs(number - x) < 1e-6
def vectors_are_equal(v1, v2):
assert len(v1) == len(v2), f"Compared vectors are not equal length: {v1}, {v2}"
return all(is_x(v1[i], v2[i]) for i in range(len(v1)))
@given("an untestable scenario")
def an_untestable_scenario():
@@ -490,7 +494,11 @@ def prop_is_value(prop, value):
exec(f"assert list(bpy.context.{prop}) == {value}")
is_value = True
except:
pass
try:
exec(f"assert vectors_are_equal(bpy.context.{prop}, {value})")
is_value = True
except:
pass
if not is_value:
print(f"bpy.context.{prop}")
actual_value = eval(f"bpy.context.{prop}")