mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-02 19:40:10 +03:00
commit
6893d1d95a
|
@ -21,19 +21,14 @@ def test_sanity():
|
||||||
|
|
||||||
|
|
||||||
def test_large_file_is_truncated():
|
def test_large_file_is_truncated():
|
||||||
import warnings
|
original_max_file_size = GimpPaletteFile._max_file_size
|
||||||
|
|
||||||
try:
|
try:
|
||||||
original_value = GimpPaletteFile._max_file_size
|
|
||||||
GimpPaletteFile._max_file_size = 100
|
GimpPaletteFile._max_file_size = 100
|
||||||
with warnings.catch_warnings():
|
with open("Tests/images/custom_gimp_palette.gpl", "rb") as fp:
|
||||||
warnings.simplefilter("error")
|
with pytest.warns(UserWarning):
|
||||||
with pytest.raises(UserWarning):
|
GimpPaletteFile(fp)
|
||||||
with open("Tests/images/custom_gimp_palette.gpl", "rb") as fp:
|
|
||||||
GimpPaletteFile(fp)
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
GimpPaletteFile._max_file_size = original_value
|
GimpPaletteFile._max_file_size = original_max_file_size
|
||||||
|
|
||||||
|
|
||||||
def test_get_palette():
|
def test_get_palette():
|
||||||
|
|
|
@ -49,7 +49,7 @@ class GimpPaletteFile:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
f"Palette file truncated at {self._max_file_size - len(s)} bytes"
|
f"Palette file truncated at {self._max_file_size - len(s)} bytes"
|
||||||
)
|
)
|
||||||
break # pragma: no cover
|
break
|
||||||
|
|
||||||
# skip fields and comment lines
|
# skip fields and comment lines
|
||||||
if re.match(rb"\w+:|#", s):
|
if re.match(rb"\w+:|#", s):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user