Add comprehensive tests for edge depth extension, empty image edits, and material view adaptation

- Introduced `test_edge_depth.py` to validate the functionality of edge depth extension, ensuring core alpha preservation, proper depth handling, and edge padding behavior.
- Created `test_empty_image_edits.py` to verify the behavior of image edits in Blender, focusing on shared edits, preservation of image properties, and handling of failed operations.
- Developed `test_material_view_adaptation.py` to test material adaptation preferences, ensuring color space and alpha settings are correctly applied and preserved across various scenarios.
This commit is contained in:
2026-09-06 21:43:47 +08:00
parent 1994d38ccd
commit 7e55af6722
58 changed files with 3607 additions and 200 deletions

View File

@@ -112,7 +112,9 @@ def load_image_modules():
package.__path__ = []
loaded = []
with patch.dict(sys.modules, {"bpy": fake_bpy, **packages}):
preferences = ModuleType("anyimage.preferences")
preferences.configured_material_view_adaptation = lambda: True
with patch.dict(sys.modules, {"bpy": fake_bpy, "anyimage.preferences": preferences, **packages}):
for module_name, module_path in module_paths:
specification = importlib.util.spec_from_file_location(
module_name,
@@ -221,14 +223,18 @@ class ImageDataTest(unittest.TestCase):
raise TypeError("unsupported color space")
self._name = value
image = SimpleNamespace(colorspace_settings=ColorSpaceSettings())
image = SimpleNamespace(
colorspace_settings=ColorSpaceSettings(),
users=0, use_fake_user=False, alpha_mode="STRAIGHT",
)
scene = SimpleNamespace(
view_settings=SimpleNamespace(view_transform="ACES 2.0")
)
result = self.image_depth.set_material_color_space(image, scene)
result = self.image_depth.configure_material_color_image(image, scene)
self.assertEqual(result, "sRGB")
self.assertIs(result, image)
self.assertEqual(image.alpha_mode, "PREMUL")
self.assertEqual(image.colorspace_settings.name, "sRGB")
def test_is_animated_image_accepts_movie_and_sequence(self):