Skip to content

Commit 68ccf47

Browse files
committed
Close file pointer earlier
1 parent bd39801 commit 68ccf47

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Tests/test_file_bmp.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ def test_rle8() -> None:
190190
# Signal end of bitmap before the image is finished
191191
with open("Tests/images/bmp/g/pal8rle.bmp", "rb") as fp:
192192
data = fp.read(1063) + b"\x01"
193-
with Image.open(io.BytesIO(data)) as im:
194-
with pytest.raises(ValueError):
195-
im.load()
193+
with Image.open(io.BytesIO(data)) as im:
194+
with pytest.raises(ValueError):
195+
im.load()
196196

197197

198198
def test_rle4() -> None:
@@ -214,9 +214,9 @@ def test_rle4() -> None:
214214
def test_rle8_eof(file_name: str, length: int) -> None:
215215
with open(file_name, "rb") as fp:
216216
data = fp.read(length)
217-
with Image.open(io.BytesIO(data)) as im:
218-
with pytest.raises(ValueError):
219-
im.load()
217+
with Image.open(io.BytesIO(data)) as im:
218+
with pytest.raises(ValueError):
219+
im.load()
220220

221221

222222
def test_offset() -> None:

Tests/test_file_jpeg2k.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ def test_comment() -> None:
457457
# Test an image that is truncated partway through a codestream
458458
with open("Tests/images/comment.jp2", "rb") as fp:
459459
b = BytesIO(fp.read(130))
460-
with Image.open(b) as im:
461-
pass
460+
with Image.open(b) as im:
461+
pass
462462

463463

464464
def test_save_comment(card: ImageFile.ImageFile) -> None:

Tests/test_file_libtiff.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,12 +1050,12 @@ def test_old_style_jpeg_orientation(self) -> None:
10501050
with open("Tests/images/old-style-jpeg-compression.tif", "rb") as fp:
10511051
data = fp.read()
10521052

1053-
# Set EXIF Orientation to 2
1054-
data = data[:102] + b"\x02" + data[103:]
1053+
# Set EXIF Orientation to 2
1054+
data = data[:102] + b"\x02" + data[103:]
10551055

1056-
with Image.open(io.BytesIO(data)) as im:
1057-
im = im.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
1058-
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
1056+
with Image.open(io.BytesIO(data)) as im:
1057+
im = im.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
1058+
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
10591059

10601060
def test_open_missing_samplesperpixel(self) -> None:
10611061
with Image.open(

0 commit comments

Comments
 (0)