mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Skip font tests when ImageFont not available
This commit is contained in:
		
							parent
							
								
									9050b47169
								
							
						
					
					
						commit
						67e5540021
					
				| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
import os.path
 | 
					import os.path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from helper import PillowTestCase, hopper, unittest
 | 
					from helper import PillowTestCase, hopper, unittest
 | 
				
			||||||
from PIL import Image, ImageDraw2
 | 
					from PIL import Image, ImageDraw2, features
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BLACK = (0, 0, 0)
 | 
					BLACK = (0, 0, 0)
 | 
				
			||||||
WHITE = (255, 255, 255)
 | 
					WHITE = (255, 255, 255)
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,7 @@ POINTS2 = [10, 10, 20, 40, 30, 30]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
KITE_POINTS = [(10, 50), (70, 10), (90, 50), (70, 90), (10, 50)]
 | 
					KITE_POINTS = [(10, 50), (70, 10), (90, 50), (70, 90), (10, 50)]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					HAS_FREETYPE = features.check("freetype2")
 | 
				
			||||||
FONT_PATH = "Tests/fonts/FreeMono.ttf"
 | 
					FONT_PATH = "Tests/fonts/FreeMono.ttf"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,6 +136,7 @@ class TestImageDraw(PillowTestCase):
 | 
				
			||||||
        # Assert
 | 
					        # Assert
 | 
				
			||||||
        self.assert_image_similar(im, Image.open(expected), 1)
 | 
					        self.assert_image_similar(im, Image.open(expected), 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @unittest.skipUnless(HAS_FREETYPE, "ImageFont not available")
 | 
				
			||||||
    def test_text(self):
 | 
					    def test_text(self):
 | 
				
			||||||
        # Arrange
 | 
					        # Arrange
 | 
				
			||||||
        im = Image.new("RGB", (W, H))
 | 
					        im = Image.new("RGB", (W, H))
 | 
				
			||||||
| 
						 | 
					@ -148,6 +150,7 @@ class TestImageDraw(PillowTestCase):
 | 
				
			||||||
        # Assert
 | 
					        # Assert
 | 
				
			||||||
        self.assert_image_similar(im, Image.open(expected), 13)
 | 
					        self.assert_image_similar(im, Image.open(expected), 13)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @unittest.skipUnless(HAS_FREETYPE, "ImageFont not available")
 | 
				
			||||||
    def test_textsize(self):
 | 
					    def test_textsize(self):
 | 
				
			||||||
        # Arrange
 | 
					        # Arrange
 | 
				
			||||||
        im = Image.new("RGB", (W, H))
 | 
					        im = Image.new("RGB", (W, H))
 | 
				
			||||||
| 
						 | 
					@ -160,6 +163,7 @@ class TestImageDraw(PillowTestCase):
 | 
				
			||||||
        # Assert
 | 
					        # Assert
 | 
				
			||||||
        self.assertEqual(size[1], 12)
 | 
					        self.assertEqual(size[1], 12)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @unittest.skipUnless(HAS_FREETYPE, "ImageFont not available")
 | 
				
			||||||
    def test_textsize_empty_string(self):
 | 
					    def test_textsize_empty_string(self):
 | 
				
			||||||
        # Arrange
 | 
					        # Arrange
 | 
				
			||||||
        im = Image.new("RGB", (W, H))
 | 
					        im = Image.new("RGB", (W, H))
 | 
				
			||||||
| 
						 | 
					@ -173,6 +177,7 @@ class TestImageDraw(PillowTestCase):
 | 
				
			||||||
        draw.textsize("\n", font)
 | 
					        draw.textsize("\n", font)
 | 
				
			||||||
        draw.textsize("test\n", font)
 | 
					        draw.textsize("test\n", font)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @unittest.skipUnless(HAS_FREETYPE, "ImageFont not available")
 | 
				
			||||||
    def test_flush(self):
 | 
					    def test_flush(self):
 | 
				
			||||||
        # Arrange
 | 
					        # Arrange
 | 
				
			||||||
        im = Image.new("RGB", (W, H))
 | 
					        im = Image.new("RGB", (W, H))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ class SimplePatcher(object):
 | 
				
			||||||
            delattr(self._parent_obj, self._attr_name)
 | 
					            delattr(self._parent_obj, self._attr_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@unittest.skipUnless(HAS_FREETYPE, "ImageFont not Available")
 | 
					@unittest.skipUnless(HAS_FREETYPE, "ImageFont not available")
 | 
				
			||||||
class TestImageFont(PillowTestCase):
 | 
					class TestImageFont(PillowTestCase):
 | 
				
			||||||
    LAYOUT_ENGINE = ImageFont.LAYOUT_BASIC
 | 
					    LAYOUT_ENGINE = ImageFont.LAYOUT_BASIC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user