mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-30 23:47:27 +03:00 
			
		
		
		
	Test saving with incorrect mode
This commit is contained in:
		
							parent
							
								
									9bed79e426
								
							
						
					
					
						commit
						dbd3c7c9b9
					
				|  | @ -4,7 +4,7 @@ from itertools import product | ||||||
| 
 | 
 | ||||||
| from PIL import Image | from PIL import Image | ||||||
| 
 | 
 | ||||||
| from .helper import PillowTestCase | from .helper import PillowTestCase, hopper | ||||||
| 
 | 
 | ||||||
| _TGA_DIR = os.path.join("Tests", "images", "tga") | _TGA_DIR = os.path.join("Tests", "images", "tga") | ||||||
| _TGA_DIR_COMMON = os.path.join(_TGA_DIR, "common") | _TGA_DIR_COMMON = os.path.join(_TGA_DIR, "common") | ||||||
|  | @ -112,6 +112,13 @@ class TestFileTga(PillowTestCase): | ||||||
|         with Image.open(out) as test_im: |         with Image.open(out) as test_im: | ||||||
|             self.assertEqual(test_im.size, (100, 100)) |             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): |     def test_save_id_section(self): | ||||||
|         test_file = "Tests/images/rgb32rle.tga" |         test_file = "Tests/images/rgb32rle.tga" | ||||||
|         with Image.open(test_file) as im: |         with Image.open(test_file) as im: | ||||||
|  |  | ||||||
|  | @ -2,7 +2,7 @@ from io import BytesIO | ||||||
| 
 | 
 | ||||||
| from PIL import Image | from PIL import Image | ||||||
| 
 | 
 | ||||||
| from .helper import PillowTestCase | from .helper import PillowTestCase, hopper | ||||||
| 
 | 
 | ||||||
| PIL151 = b""" | PIL151 = b""" | ||||||
| #define basic_width 32 | #define basic_width 32 | ||||||
|  | @ -58,3 +58,10 @@ class TestFileXbm(PillowTestCase): | ||||||
|             # Assert |             # Assert | ||||||
|             self.assertEqual(im.mode, "1") |             self.assertEqual(im.mode, "1") | ||||||
|             self.assertEqual(im.size, (128, 128)) |             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) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user