Skip to content

Commit dbd3c7c

Browse files
committed
Test saving with incorrect mode
1 parent 9bed79e commit dbd3c7c

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

Tests/test_file_tga.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from PIL import Image
66

7-
from .helper import PillowTestCase
7+
from .helper import PillowTestCase, hopper
88

99
_TGA_DIR = os.path.join("Tests", "images", "tga")
1010
_TGA_DIR_COMMON = os.path.join(_TGA_DIR, "common")
@@ -112,6 +112,13 @@ def test_save(self):
112112
with Image.open(out) as test_im:
113113
self.assertEqual(test_im.size, (100, 100))
114114

115+
def test_save_wrong_mode(self):
116+
im = hopper("PA")
117+
out = self.tempfile("temp.tga")
118+
119+
with self.assertRaises(OSError):
120+
im.save(out)
121+
115122
def test_save_id_section(self):
116123
test_file = "Tests/images/rgb32rle.tga"
117124
with Image.open(test_file) as im:

Tests/test_file_xbm.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from PIL import Image
44

5-
from .helper import PillowTestCase
5+
from .helper import PillowTestCase, hopper
66

77
PIL151 = b"""
88
#define basic_width 32
@@ -58,3 +58,10 @@ def test_open_filename_with_underscore(self):
5858
# Assert
5959
self.assertEqual(im.mode, "1")
6060
self.assertEqual(im.size, (128, 128))
61+
62+
def test_save_wrong_mode(self):
63+
im = hopper()
64+
out = self.tempfile("temp.xbm")
65+
66+
with self.assertRaises(OSError):
67+
im.save(out)

0 commit comments

Comments
 (0)