Enhance image editing tests and functionality

- Added parameterized tests for image edit replacement to ensure alpha mode preservation.
- Refactored existing tests to utilize new image editing methods and improve clarity.
- Introduced new tests for image target functionality, ensuring proper handling of shared textures and context.
- Updated various tests to validate alpha mode handling across different scenarios.
- Improved undo/redo functionality in image operators to maintain state consistency.
- Added support for texture node actions, enhancing integration with Blender's node system.
- Ensured that image properties are preserved during operations and that invalid contexts are handled gracefully.
This commit is contained in:
2026-09-10 00:00:13 +08:00
parent f48bbb3d05
commit 1622afa7a2
28 changed files with 1068 additions and 236 deletions

View File

@@ -96,12 +96,12 @@ class ImageMenuTest(BlenderTestCase):
def test_image_operators_stay_clickable_until_server_is_busy(self):
context = SimpleNamespace(
object=SimpleNamespace(data=SimpleNamespace()),
object=SimpleNamespace(type="EMPTY", empty_display_type="IMAGE", data=SimpleNamespace()),
)
operators = (
(self.convert_to_plane, self.convert_to_plane.ConvertToDepthPlane),
(self.convert_to_plane, self.convert_to_plane.ConvertToReliefPlane),
(self.remove_background, self.remove_background.RemoveImageBackground),
self.convert_to_plane.ConvertToDepthPlane,
self.convert_to_plane.ConvertToReliefPlane,
self.remove_background.RemoveImageBackground,
)
for busy, expected in ((False, True), (True, False)):
@@ -113,18 +113,6 @@ class ImageMenuTest(BlenderTestCase):
return_value=busy,
),
):
for module, operator in operators:
with (
self.subTest(operator=operator.__name__),
patch.object(
module,
"is_image_empty",
return_value=True,
),
patch.object(
module,
"video_total_frames",
return_value=1,
),
):
for operator in operators:
with self.subTest(operator=operator.__name__):
self.assertEqual(operator.poll(context), expected)