mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Similar to the recent adoption of Black. isort is a Python utility to sort imports alphabetically and automatically separate into sections. By using isort, contributors can quickly and automatically conform to the projects style without thinking. Just let the tool do it. Uses the configuration recommended by the Black to avoid conflicts of style. Rewrite TestImageQt.test_deprecated to no rely on import order.
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
from PIL import Image
 | 
						|
 | 
						|
from .helper import PillowTestCase, hopper
 | 
						|
 | 
						|
 | 
						|
class TestImageGetBbox(PillowTestCase):
 | 
						|
    def test_sanity(self):
 | 
						|
 | 
						|
        bbox = hopper().getbbox()
 | 
						|
        self.assertIsInstance(bbox, tuple)
 | 
						|
 | 
						|
    def test_bbox(self):
 | 
						|
 | 
						|
        # 8-bit mode
 | 
						|
        im = Image.new("L", (100, 100), 0)
 | 
						|
        self.assertIsNone(im.getbbox())
 | 
						|
 | 
						|
        im.paste(255, (10, 25, 90, 75))
 | 
						|
        self.assertEqual(im.getbbox(), (10, 25, 90, 75))
 | 
						|
 | 
						|
        im.paste(255, (25, 10, 75, 90))
 | 
						|
        self.assertEqual(im.getbbox(), (10, 10, 90, 90))
 | 
						|
 | 
						|
        im.paste(255, (-10, -10, 110, 110))
 | 
						|
        self.assertEqual(im.getbbox(), (0, 0, 100, 100))
 | 
						|
 | 
						|
        # 32-bit mode
 | 
						|
        im = Image.new("RGB", (100, 100), 0)
 | 
						|
        self.assertIsNone(im.getbbox())
 | 
						|
 | 
						|
        im.paste(255, (10, 25, 90, 75))
 | 
						|
        self.assertEqual(im.getbbox(), (10, 25, 90, 75))
 | 
						|
 | 
						|
        im.paste(255, (25, 10, 75, 90))
 | 
						|
        self.assertEqual(im.getbbox(), (10, 10, 90, 90))
 | 
						|
 | 
						|
        im.paste(255, (-10, -10, 110, 110))
 | 
						|
        self.assertEqual(im.getbbox(), (0, 0, 100, 100))
 |