Load before trying to catch exceptions

This commit is contained in:
Andrew Murray 2024-09-21 16:22:50 +10:00
parent af521a1ce1
commit aa22b24169

View File

@ -324,17 +324,17 @@ def test_set_lut() -> None:
def test_wrong_mode() -> None:
lut = ImageMorph.LutBuilder(op_name="corner").build_lut()
imrgb = Image.new("RGB", (10, 10))
iml = Image.new("L", (10, 10))
imrgb_ptr = Image.new("RGB", (10, 10)).getim()
iml_ptr = Image.new("L", (10, 10)).getim()
with pytest.raises(RuntimeError):
_imagingmorph.apply(bytes(lut), imrgb.getim(), iml.getim())
_imagingmorph.apply(bytes(lut), imrgb_ptr, iml_ptr)
with pytest.raises(RuntimeError):
_imagingmorph.apply(bytes(lut), iml.getim(), imrgb.getim())
_imagingmorph.apply(bytes(lut), iml_ptr, imrgb_ptr)
with pytest.raises(RuntimeError):
_imagingmorph.match(bytes(lut), imrgb.getim())
_imagingmorph.match(bytes(lut), imrgb_ptr)
# Should not raise
_imagingmorph.match(bytes(lut), iml.getim())
_imagingmorph.match(bytes(lut), iml_ptr)