mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 16:22:22 +03:00
added test to improve coverage for _save func
This commit is contained in:
parent
5701d33cbb
commit
3c9b4f60ab
|
@ -4,6 +4,9 @@ import tempfile
|
|||
import warnings
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
import unittest
|
||||
import struct
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -162,3 +165,30 @@ def test_odd_size() -> None:
|
|||
data.seek(0)
|
||||
with Image.open(data) as im2:
|
||||
assert_image_equal(im, im2)
|
||||
|
||||
|
||||
def test_seek_no_frame() -> None:
|
||||
with Image.open(TEST_FILE) as im:
|
||||
im.istack = 1
|
||||
im.seek(0)
|
||||
|
||||
|
||||
def test_save_small_header():
|
||||
width, height = 10, 10
|
||||
im = Image.new("F", (width, height))
|
||||
|
||||
fp = BytesIO()
|
||||
|
||||
corrupted_header = [b'\x00' * 4] * 22
|
||||
|
||||
with patch("PIL.SpiderImagePlugin.makeSpiderHeader", return_value=corrupted_header):
|
||||
try:
|
||||
# Attempt to save the image
|
||||
im.save(fp, format="SPIDER")
|
||||
except OSError as e:
|
||||
# Check if the correct exception is raised
|
||||
assert str(e) == "Error creating Spider header"
|
||||
else:
|
||||
# If no exception is raised, the test has failed
|
||||
assert False, "Expected an OSError due to corrupted header"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user