mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Make tests more robust re: https://github.com/python-pillow/Pillow/issues/947#issuecomment-61641247
This commit is contained in:
		
							parent
							
								
									529eebd3c0
								
							
						
					
					
						commit
						0e23d74173
					
				| 
						 | 
					@ -76,7 +76,8 @@ class TestNumpy(PillowTestCase):
 | 
				
			||||||
        self.assert_image(Image.fromarray(a[:, :, 1]), "L", (10, 10))
 | 
					        self.assert_image(Image.fromarray(a[:, :, 1]), "L", (10, 10))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _test_img_equals_nparray(self, img, np):
 | 
					    def _test_img_equals_nparray(self, img, np):
 | 
				
			||||||
        self.assertEqual(img.size, np.shape[0:2])
 | 
					        np_size = np.shape[1], np.shape[0]
 | 
				
			||||||
 | 
					        self.assertEqual(img.size, np_size)
 | 
				
			||||||
        px = img.load()
 | 
					        px = img.load()
 | 
				
			||||||
        for x in range(0, img.size[0], int(img.size[0]/10)):
 | 
					        for x in range(0, img.size[0], int(img.size[0]/10)):
 | 
				
			||||||
            for y in range(0, img.size[1], int(img.size[1]/10)):
 | 
					            for y in range(0, img.size[1], int(img.size[1]/10)):
 | 
				
			||||||
| 
						 | 
					@ -92,6 +93,11 @@ class TestNumpy(PillowTestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def _to_array(mode, dtype):
 | 
					        def _to_array(mode, dtype):
 | 
				
			||||||
            img = hopper(mode)
 | 
					            img = hopper(mode)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            # Resize to non-square
 | 
				
			||||||
 | 
					            img = img.crop((3, 0, 124, 127))
 | 
				
			||||||
 | 
					            self.assertEqual(img.size, (121, 127))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            np_img = numpy.array(img)
 | 
					            np_img = numpy.array(img)
 | 
				
			||||||
            self._test_img_equals_nparray(img, np_img)
 | 
					            self._test_img_equals_nparray(img, np_img)
 | 
				
			||||||
            self.assertEqual(np_img.dtype, numpy.dtype(dtype))
 | 
					            self.assertEqual(np_img.dtype, numpy.dtype(dtype))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user