Test saving with incorrect mode

This commit is contained in:
Andrew Murray 2020-01-14 20:51:56 +11:00
parent 9bed79e426
commit dbd3c7c9b9
2 changed files with 16 additions and 2 deletions

View File

@ -4,7 +4,7 @@ from itertools import product
from PIL import Image
from .helper import PillowTestCase
from .helper import PillowTestCase, hopper
_TGA_DIR = os.path.join("Tests", "images", "tga")
_TGA_DIR_COMMON = os.path.join(_TGA_DIR, "common")
@ -112,6 +112,13 @@ class TestFileTga(PillowTestCase):
with Image.open(out) as test_im:
self.assertEqual(test_im.size, (100, 100))
def test_save_wrong_mode(self):
im = hopper("PA")
out = self.tempfile("temp.tga")
with self.assertRaises(OSError):
im.save(out)
def test_save_id_section(self):
test_file = "Tests/images/rgb32rle.tga"
with Image.open(test_file) as im:

View File

@ -2,7 +2,7 @@ from io import BytesIO
from PIL import Image
from .helper import PillowTestCase
from .helper import PillowTestCase, hopper
PIL151 = b"""
#define basic_width 32
@ -58,3 +58,10 @@ class TestFileXbm(PillowTestCase):
# Assert
self.assertEqual(im.mode, "1")
self.assertEqual(im.size, (128, 128))
def test_save_wrong_mode(self):
im = hopper()
out = self.tempfile("temp.xbm")
with self.assertRaises(OSError):
im.save(out)