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