mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-04 12:30:09 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
a12389bf35
commit
2f6467c94e
|
@ -23,6 +23,7 @@ def test_sanity():
|
||||||
def test_large_file_is_truncated():
|
def test_large_file_is_truncated():
|
||||||
import warnings
|
import warnings
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
try:
|
try:
|
||||||
original_value = GimpPaletteFile._max_file_size
|
original_value = GimpPaletteFile._max_file_size
|
||||||
GimpPaletteFile._max_file_size = 100
|
GimpPaletteFile._max_file_size = 100
|
||||||
|
@ -35,6 +36,7 @@ def test_large_file_is_truncated():
|
||||||
finally:
|
finally:
|
||||||
GimpPaletteFile._max_file_size = original_value
|
GimpPaletteFile._max_file_size = original_value
|
||||||
|
|
||||||
|
|
||||||
def test_get_palette():
|
def test_get_palette():
|
||||||
# Arrange
|
# Arrange
|
||||||
with open("Tests/images/custom_gimp_palette.gpl", "rb") as fp:
|
with open("Tests/images/custom_gimp_palette.gpl", "rb") as fp:
|
||||||
|
|
|
@ -28,7 +28,7 @@ class GimpPaletteFile:
|
||||||
#: override if reading larger palettes is needed
|
#: override if reading larger palettes is needed
|
||||||
max_colors = 256
|
max_colors = 256
|
||||||
_max_line_size = 100
|
_max_line_size = 100
|
||||||
_max_file_size = 2 ** 20
|
_max_file_size = 2**20
|
||||||
|
|
||||||
def __init__(self, fp):
|
def __init__(self, fp):
|
||||||
|
|
||||||
|
@ -47,7 +47,8 @@ class GimpPaletteFile:
|
||||||
read += len(s)
|
read += len(s)
|
||||||
if read >= self._max_file_size:
|
if read >= self._max_file_size:
|
||||||
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
|
break
|
||||||
|
|
||||||
# skip fields and comment lines
|
# skip fields and comment lines
|
||||||
|
|
Loading…
Reference in New Issue
Block a user