mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
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:
@@ -365,9 +365,9 @@ Scenario: Animate the construction of a wall
|
|||||||
When I am on frame "2"
|
When I am on frame "2"
|
||||||
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
||||||
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
||||||
And "scene.objects.get('IfcWall/Cube').color" is "[0.0, 1.0, 0.0, 1]"
|
And "scene.objects.get('IfcWall/Cube').color[:]" is "[0.0, 1.0, 0.0, 1]"
|
||||||
When I am on frame "7"
|
When I am on frame "7"
|
||||||
Then "scene.objects.get('IfcWall/Cube').color" is "[1.0, 1.0, 1.0, 1]"
|
Then "scene.objects.get('IfcWall/Cube').color[:]" is "[1.0, 1.0, 1.0, 1]"
|
||||||
|
|
||||||
Scenario: Animate the demolition of a wall
|
Scenario: Animate the demolition of a wall
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
@@ -398,15 +398,15 @@ Scenario: Animate the demolition of a wall
|
|||||||
When I am on frame "1"
|
When I am on frame "1"
|
||||||
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
||||||
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
||||||
And "scene.objects.get('IfcWall/Cube').color" is "[1.0, 1.0, 1.0, 1]"
|
And "scene.objects.get('IfcWall/Cube').color[:]" is "[1.0, 1.0, 1.0, 1]"
|
||||||
When I am on frame "2"
|
When I am on frame "2"
|
||||||
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
||||||
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
||||||
And "scene.objects.get('IfcWall/Cube').color" is "[1.0, 0.0, 0.0, 1]"
|
And "scene.objects.get('IfcWall/Cube').color[:]" is "[1.0, 0.0, 0.0, 1]"
|
||||||
When I am on frame "7"
|
When I am on frame "7"
|
||||||
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "True"
|
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "True"
|
||||||
And "scene.objects.get('IfcWall/Cube').hide_render" is "True"
|
And "scene.objects.get('IfcWall/Cube').hide_render" is "True"
|
||||||
And "scene.objects.get('IfcWall/Cube').color" is "[0.0, 0.0, 0.0, 1]"
|
And "scene.objects.get('IfcWall/Cube').color[:]" is "[0.0, 0.0, 0.0, 1]"
|
||||||
|
|
||||||
Scenario: Animate the operation of a wall
|
Scenario: Animate the operation of a wall
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
@@ -435,11 +435,11 @@ Scenario: Animate the operation of a wall
|
|||||||
And I set "scene.BIMWorkScheduleProperties.speed_real_duration" to "P1W"
|
And I set "scene.BIMWorkScheduleProperties.speed_real_duration" to "P1W"
|
||||||
And I press "bim.visualise_work_schedule_date_range(work_schedule={work_schedule})"
|
And I press "bim.visualise_work_schedule_date_range(work_schedule={work_schedule})"
|
||||||
When I am on frame "1"
|
When I am on frame "1"
|
||||||
Then "scene.objects.get('IfcWall/Cube').color" is "[1.0, 1.0, 1.0, 1]"
|
Then "scene.objects.get('IfcWall/Cube').color[:]" is "[1.0, 1.0, 1.0, 1]"
|
||||||
When I am on frame "2"
|
When I am on frame "2"
|
||||||
Then "scene.objects.get('IfcWall/Cube').color" is "[0.0, 0.0, 1.0, 1]"
|
Then "scene.objects.get('IfcWall/Cube').color[:]" is "[0.0, 0.0, 1.0, 1]"
|
||||||
When I am on frame "7"
|
When I am on frame "7"
|
||||||
Then "scene.objects.get('IfcWall/Cube').color" is "[1.0, 1.0, 1.0, 1]"
|
Then "scene.objects.get('IfcWall/Cube').color[:]" is "[1.0, 1.0, 1.0, 1]"
|
||||||
|
|
||||||
Scenario: Animate the movement of a wall
|
Scenario: Animate the movement of a wall
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
@@ -475,23 +475,23 @@ Scenario: Animate the movement of a wall
|
|||||||
And I set "scene.BIMWorkScheduleProperties.speed_real_duration" to "P1W"
|
And I set "scene.BIMWorkScheduleProperties.speed_real_duration" to "P1W"
|
||||||
And I press "bim.visualise_work_schedule_date_range(work_schedule={work_schedule})"
|
And I press "bim.visualise_work_schedule_date_range(work_schedule={work_schedule})"
|
||||||
When I am on frame "1"
|
When I am on frame "1"
|
||||||
Then "scene.objects.get('IfcWall/FromObject').color" is "[1.0, 1.0, 1.0, 1]"
|
Then "scene.objects.get('IfcWall/FromObject').color[:]" is "[1.0, 1.0, 1.0, 1]"
|
||||||
And "scene.objects.get('IfcWall/FromObject').hide_viewport" is "False"
|
And "scene.objects.get('IfcWall/FromObject').hide_viewport" is "False"
|
||||||
And "scene.objects.get('IfcWall/FromObject').hide_render" is "False"
|
And "scene.objects.get('IfcWall/FromObject').hide_render" is "False"
|
||||||
And "scene.objects.get('IfcWall/ToObject').hide_viewport" is "True"
|
And "scene.objects.get('IfcWall/ToObject').hide_viewport" is "True"
|
||||||
And "scene.objects.get('IfcWall/ToObject').hide_render" is "True"
|
And "scene.objects.get('IfcWall/ToObject').hide_render" is "True"
|
||||||
When I am on frame "2"
|
When I am on frame "2"
|
||||||
Then "scene.objects.get('IfcWall/FromObject').color" is "[1.0, 0.5, 0.0, 1]"
|
Then "scene.objects.get('IfcWall/FromObject').color[:]" is "[1.0, 0.5, 0.0, 1]"
|
||||||
And "scene.objects.get('IfcWall/FromObject').hide_viewport" is "False"
|
And "scene.objects.get('IfcWall/FromObject').hide_viewport" is "False"
|
||||||
And "scene.objects.get('IfcWall/FromObject').hide_render" is "False"
|
And "scene.objects.get('IfcWall/FromObject').hide_render" is "False"
|
||||||
And "scene.objects.get('IfcWall/ToObject').color" is "[1.0, 1.0, 0.0, 1]"
|
And "scene.objects.get('IfcWall/ToObject').color[:]" is "[1.0, 1.0, 0.0, 1]"
|
||||||
And "scene.objects.get('IfcWall/ToObject').hide_viewport" is "False"
|
And "scene.objects.get('IfcWall/ToObject').hide_viewport" is "False"
|
||||||
And "scene.objects.get('IfcWall/ToObject').hide_render" is "False"
|
And "scene.objects.get('IfcWall/ToObject').hide_render" is "False"
|
||||||
When I am on frame "7"
|
When I am on frame "7"
|
||||||
Then "scene.objects.get('IfcWall/FromObject').color" is "[0.0, 0.0, 0.0, 1]"
|
Then "scene.objects.get('IfcWall/FromObject').color[:]" is "[0.0, 0.0, 0.0, 1]"
|
||||||
Then "scene.objects.get('IfcWall/FromObject').hide_viewport" is "True"
|
Then "scene.objects.get('IfcWall/FromObject').hide_viewport" is "True"
|
||||||
Then "scene.objects.get('IfcWall/FromObject').hide_render" is "True"
|
Then "scene.objects.get('IfcWall/FromObject').hide_render" is "True"
|
||||||
And "scene.objects.get('IfcWall/ToObject').color" is "[1.0, 1.0, 1.0, 1]"
|
And "scene.objects.get('IfcWall/ToObject').color[:]" is "[1.0, 1.0, 1.0, 1]"
|
||||||
And "scene.objects.get('IfcWall/ToObject').hide_viewport" is "False"
|
And "scene.objects.get('IfcWall/ToObject').hide_viewport" is "False"
|
||||||
And "scene.objects.get('IfcWall/ToObject').hide_render" is "False"
|
And "scene.objects.get('IfcWall/ToObject').hide_render" is "False"
|
||||||
|
|
||||||
@@ -519,15 +519,15 @@ Scenario: Animate the consumption of a wall
|
|||||||
And I set "scene.BIMWorkScheduleProperties.speed_real_duration" to "P1W"
|
And I set "scene.BIMWorkScheduleProperties.speed_real_duration" to "P1W"
|
||||||
And I press "bim.visualise_work_schedule_date_range(work_schedule={work_schedule})"
|
And I press "bim.visualise_work_schedule_date_range(work_schedule={work_schedule})"
|
||||||
When I am on frame "1"
|
When I am on frame "1"
|
||||||
Then "scene.objects.get('IfcWall/Cube').color" is "[1.0, 1.0, 1.0, 1]"
|
Then "scene.objects.get('IfcWall/Cube').color[:]" is "[1.0, 1.0, 1.0, 1]"
|
||||||
And "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
And "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
||||||
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
||||||
When I am on frame "2"
|
When I am on frame "2"
|
||||||
Then "scene.objects.get('IfcWall/Cube').color" is "[0.2, 0.2, 0.2, 1]"
|
Then "scene.objects.get('IfcWall/Cube').color[:]" is "[0.2, 0.2, 0.2, 1]"
|
||||||
And "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
And "scene.objects.get('IfcWall/Cube').hide_viewport" is "False"
|
||||||
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
And "scene.objects.get('IfcWall/Cube').hide_render" is "False"
|
||||||
When I am on frame "7"
|
When I am on frame "7"
|
||||||
Then "scene.objects.get('IfcWall/Cube').color" is "[0.0, 0.0, 0.0, 1]"
|
Then "scene.objects.get('IfcWall/Cube').color[:]" is "[0.0, 0.0, 0.0, 1]"
|
||||||
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "True"
|
Then "scene.objects.get('IfcWall/Cube').hide_viewport" is "True"
|
||||||
Then "scene.objects.get('IfcWall/Cube').hide_render" is "True"
|
Then "scene.objects.get('IfcWall/Cube').hide_render" is "True"
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ def replace_variables(value):
|
|||||||
def is_x(number, x):
|
def is_x(number, x):
|
||||||
return abs(number - x) < 1e-6
|
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")
|
@given("an untestable scenario")
|
||||||
def 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}")
|
exec(f"assert list(bpy.context.{prop}) == {value}")
|
||||||
is_value = True
|
is_value = True
|
||||||
except:
|
except:
|
||||||
pass
|
try:
|
||||||
|
exec(f"assert vectors_are_equal(bpy.context.{prop}, {value})")
|
||||||
|
is_value = True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if not is_value:
|
if not is_value:
|
||||||
print(f"bpy.context.{prop}")
|
print(f"bpy.context.{prop}")
|
||||||
actual_value = eval(f"bpy.context.{prop}")
|
actual_value = eval(f"bpy.context.{prop}")
|
||||||
|
|||||||
Reference in New Issue
Block a user