Refactor tests and remove unused imports
- Cleaned up test files by removing unnecessary imports and unused parameters. - Simplified test functions by eliminating redundant parameterization and consolidating logic. - Updated test cases to directly use defined values instead of parameterized inputs where applicable. - Enhanced readability and maintainability of the test code across various test files.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import bpy
|
||||
import pytest
|
||||
|
||||
from anyimage.common.object import (
|
||||
modifier_input_identifier,
|
||||
@@ -18,15 +17,14 @@ def evaluated_mesh(obj):
|
||||
return evaluated, evaluated.to_mesh()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source_count", [0, 4, 9])
|
||||
def test_material_inheritance_removes_only_source_vertices(source_count):
|
||||
def test_material_inheritance_removes_only_source_vertices():
|
||||
from tools.nodes.common.material_slots import inherit_material_slots
|
||||
from tools.nodes.arrangement.arrange import arrange_nodes
|
||||
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
source_count = 4
|
||||
mesh = bpy.data.meshes.new("Source")
|
||||
mesh.from_pydata([(20 + i % 3, i // 3, 0) for i in range(source_count)], [],
|
||||
[(0, 1, 3, 2)] if source_count else [])
|
||||
[(0, 1, 3, 2)])
|
||||
materials = [bpy.data.materials.new(name) for name in ("First", "Second")]
|
||||
for material in materials:
|
||||
mesh.materials.append(material)
|
||||
@@ -42,20 +40,16 @@ def test_material_inheritance_removes_only_source_vertices(source_count):
|
||||
geometry = inherit_material_slots(group, grid.outputs["Mesh"], source.outputs["Geometry"])
|
||||
group.links.new(geometry, group.nodes.new("NodeGroupOutput").inputs["Geometry"])
|
||||
obj.modifiers.new("Material Inheritance", "NODES").node_group = group
|
||||
for arranged in (False, True):
|
||||
if arranged:
|
||||
arrange_nodes(group)
|
||||
obj.update_tag(refresh={"DATA"})
|
||||
ev, result = evaluated_mesh(obj)
|
||||
try:
|
||||
assert len(result.vertices) == 6 and len(result.polygons) == 2
|
||||
assert all(abs(v.co.x) <= 0.5 for v in result.vertices)
|
||||
if source_count:
|
||||
assert [material.original for material in result.materials if material] == materials
|
||||
assert result.materials[0].original == materials[0]
|
||||
assert all(face.material_index == 0 for face in result.polygons)
|
||||
finally:
|
||||
ev.to_mesh_clear()
|
||||
obj.update_tag(refresh={"DATA"})
|
||||
ev, result = evaluated_mesh(obj)
|
||||
try:
|
||||
assert len(result.vertices) == 6 and len(result.polygons) == 2
|
||||
assert all(abs(v.co.x) <= 0.5 for v in result.vertices)
|
||||
assert [material.original for material in result.materials if material] == materials
|
||||
assert result.materials[0].original == materials[0]
|
||||
assert all(face.material_index == 0 for face in result.polygons)
|
||||
finally:
|
||||
ev.to_mesh_clear()
|
||||
|
||||
|
||||
def test_saved_image_plane_evaluation():
|
||||
|
||||
Reference in New Issue
Block a user