Skip to content

Commit 14c0af8

Browse files
committed
Operations must have length 1
1 parent 640f55a commit 14c0af8

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Tests/test_imagemorph.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from PIL import Image, ImageMorph, _imagingmorph
99

10-
from .helper import assert_image_equal_tofile, hopper
10+
from .helper import assert_image_equal_tofile, hopper, timeout_unless_slower_valgrind
1111

1212

1313
def string_to_img(image_string: str) -> Image.Image:
@@ -266,16 +266,18 @@ def test_unknown_pattern() -> None:
266266
ImageMorph.LutBuilder(op_name="unknown")
267267

268268

269-
def test_pattern_syntax_error() -> None:
269+
@pytest.mark.parametrize(
270+
"pattern", ("a pattern with a syntax error", "4:(" + "X" * 30000)
271+
)
272+
@timeout_unless_slower_valgrind(1)
273+
def test_pattern_syntax_error(pattern: str) -> None:
270274
# Arrange
271275
lb = ImageMorph.LutBuilder(op_name="corner")
272-
new_patterns = ["a pattern with a syntax error"]
276+
new_patterns = [pattern]
273277
lb.add_patterns(new_patterns)
274278

275279
# Act / Assert
276-
with pytest.raises(
277-
Exception, match='Syntax error in pattern "a pattern with a syntax error"'
278-
):
280+
with pytest.raises(Exception, match='Syntax error in pattern "'):
279281
lb.build_lut()
280282

281283

src/PIL/ImageMorph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def build_lut(self) -> bytearray:
150150

151151
# Parse and create symmetries of the patterns strings
152152
for p in self.patterns:
153-
m = re.search(r"(\w*):?\s*\((.+?)\)\s*->\s*(\d)", p.replace("\n", ""))
153+
m = re.search(r"(\w):?\s*\((.+?)\)\s*->\s*(\d)", p.replace("\n", ""))
154154
if not m:
155155
msg = 'Syntax error in pattern "' + p + '"'
156156
raise Exception(msg)

0 commit comments

Comments
 (0)