Skip to content

Commit ef723c9

Browse files
committed
test_tobytes
1 parent 27a8852 commit ef723c9

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

Tests/test_map.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,9 @@
1-
import sys
2-
31
import pytest
42

53
from PIL import Image
64

7-
from .helper import is_win32
8-
9-
pytestmark = pytest.mark.skipif(is_win32(), reason="Win32 does not call map_buffer")
10-
11-
12-
def test_overflow():
13-
# There is the potential to overflow comparisons in map.c
14-
# if there are > SIZE_MAX bytes in the image or if
15-
# the file encodes an offset that makes
16-
# (offset + size(bytes)) > SIZE_MAX
17-
18-
# Note that this image triggers the decompression bomb warning:
19-
max_pixels = Image.MAX_IMAGE_PIXELS
20-
Image.MAX_IMAGE_PIXELS = None
215

22-
# This image hits the offset test.
6+
def test_tobytes():
237
with Image.open("Tests/images/l2rgb_read.bmp") as im:
248
with pytest.raises((ValueError, MemoryError, OSError)):
25-
im.load()
26-
27-
Image.MAX_IMAGE_PIXELS = max_pixels
28-
29-
30-
@pytest.mark.skipif(sys.maxsize <= 2 ** 32, reason="Requires 64-bit system")
31-
def test_ysize():
32-
numpy = pytest.importorskip("numpy", reason="NumPy not installed")
33-
34-
# Should not raise 'Integer overflow in ysize'
35-
arr = numpy.zeros((46341, 46341), dtype=numpy.uint8)
36-
Image.fromarray(arr)
9+
im.tobytes()

0 commit comments

Comments
 (0)