Skip to content

Commit 21ff960

Browse files
committed
Test that an unlimited number of lines is not read by __init__
1 parent 510bc05 commit 21ff960

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Tests/test_file_gimppalette.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@ def test_get_palette(filename: str, size: int) -> None:
4141

4242

4343
def test_frombytes() -> None:
44-
with open("Tests/images/full_gimp_palette.gpl", "rb") as fp:
45-
full_data = fp.read()
44+
# Test that __init__ stops reading after 260 lines
45+
with open("Tests/images/custom_gimp_palette.gpl", "rb") as fp:
46+
custom_data = fp.read()
47+
custom_data += b"#\n" * 300 + b" 0 0 0 Index 12"
48+
b = BytesIO(custom_data)
49+
palette = GimpPaletteFile(b)
50+
assert len(palette.palette) / 3 == 8
4651

4752
# Test that __init__ only reads 256 entries
53+
with open("Tests/images/full_gimp_palette.gpl", "rb") as fp:
54+
full_data = fp.read()
4855
data = full_data.replace(b"#\n", b"") + b" 0 0 0 Index 256"
4956
b = BytesIO(data)
5057
palette = GimpPaletteFile(b)

0 commit comments

Comments
 (0)