mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Merge pull request #802 from hugovk/SunImagePlugin
Sanity test for SunImagePlugin.py
This commit is contained in:
		
						commit
						c22c8eefcc
					
				| 
						 | 
					@ -29,6 +29,7 @@ i32 = _binary.i32be
 | 
				
			||||||
def _accept(prefix):
 | 
					def _accept(prefix):
 | 
				
			||||||
    return i32(prefix) == 0x59a66a95
 | 
					    return i32(prefix) == 0x59a66a95
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
##
 | 
					##
 | 
				
			||||||
# Image plugin for Sun raster files.
 | 
					# Image plugin for Sun raster files.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,9 +71,9 @@ class SunImageFile(ImageFile.ImageFile):
 | 
				
			||||||
        stride = (((self.size[0] * depth + 7) // 8) + 3) & (~3)
 | 
					        stride = (((self.size[0] * depth + 7) // 8) + 3) & (~3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if compression == 1:
 | 
					        if compression == 1:
 | 
				
			||||||
            self.tile = [("raw", (0,0)+self.size, offset, (rawmode, stride))]
 | 
					            self.tile = [("raw", (0, 0)+self.size, offset, (rawmode, stride))]
 | 
				
			||||||
        elif compression == 2:
 | 
					        elif compression == 2:
 | 
				
			||||||
            self.tile = [("sun_rle", (0,0)+self.size, offset, rawmode)]
 | 
					            self.tile = [("sun_rle", (0, 0)+self.size, offset, rawmode)]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# registry
 | 
					# registry
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								Tests/images/lena.ras
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/lena.ras
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										23
									
								
								Tests/test_file_sun.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Tests/test_file_sun.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					from helper import unittest, PillowTestCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from PIL import Image
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TestFileSun(PillowTestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_sanity(self):
 | 
				
			||||||
 | 
					        # Arrange
 | 
				
			||||||
 | 
					        # Created with ImageMagick: convert lena.ppm lena.ras
 | 
				
			||||||
 | 
					        test_file = "Tests/images/lena.ras"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Act
 | 
				
			||||||
 | 
					        im = Image.open(test_file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Assert
 | 
				
			||||||
 | 
					        self.assertEqual(im.size, (128, 128))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    unittest.main()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# End of file
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user