Tests: have test_object active by default in regression test files
When opening Geometry Nodes regression test files I always find a bit annoying that the `expected_object` and not the `test_object` is active. That's because only the `test_object` contains the modifier or node tree that is being tested. Therefore, usually my first step when opening these files is to select the `test_object` first. This patch changes it so that when mesh tests are updated, the `test_object` is made active in the end before the file is saved again. Pull Request: https://projects.blender.org/blender/blender/pulls/139088
This commit is contained in:
@@ -206,6 +206,8 @@ class MeshTest(ABC):
|
||||
self.expected_object = objects[self.exp_object_name]
|
||||
else:
|
||||
self.create_expected_object()
|
||||
self.activate_test_object()
|
||||
bpy.ops.wm.save_as_mainfile(filepath=bpy.data.filepath)
|
||||
else:
|
||||
self.expected_object = objects[self.exp_object_name]
|
||||
|
||||
@@ -221,7 +223,6 @@ class MeshTest(ABC):
|
||||
self.expected_object.name = self.exp_object_name
|
||||
x, y, z = self.test_object.location
|
||||
self.expected_object.location = (x, y + 10, z)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=bpy.data.filepath)
|
||||
|
||||
def create_evaluated_object(self):
|
||||
"""
|
||||
@@ -239,6 +240,14 @@ class MeshTest(ABC):
|
||||
self.evaluated_object = bpy.context.active_object
|
||||
self.evaluated_object.name = "evaluated_object"
|
||||
|
||||
# Test files are less confusing when the test object is active initially instead of
|
||||
# the expected object. That's because the test object has the modifier/node tree that
|
||||
# is being tested.
|
||||
def activate_test_object(self):
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
self.test_object.select_set(True)
|
||||
bpy.context.view_layer.objects.active = self.test_object
|
||||
|
||||
@staticmethod
|
||||
def _print_result(result):
|
||||
"""
|
||||
@@ -378,6 +387,8 @@ class MeshTest(ABC):
|
||||
self.evaluated_object.name = expected_object_name
|
||||
self.do_selection(self.evaluated_object.data, "VERT", evaluated_selection, False)
|
||||
|
||||
self.activate_test_object()
|
||||
|
||||
# Save file.
|
||||
bpy.ops.wm.save_as_mainfile(filepath=bpy.data.filepath)
|
||||
self.test_updated_counter += 1
|
||||
|
||||
Reference in New Issue
Block a user