mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Update test as textsize() isn't implemented
This commit is contained in:
		
							parent
							
								
									6da05b4026
								
							
						
					
					
						commit
						31859521c9
					
				| 
						 | 
					@ -1,11 +1,11 @@
 | 
				
			||||||
from helper import unittest, PillowTestCase, hopper
 | 
					from helper import unittest, PillowTestCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestPsDraw(PillowTestCase):
 | 
					class TestPsDraw(PillowTestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_draw_postscript(self):
 | 
					    def test_draw_postscript(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Taken from Pillow tutorial:
 | 
					        # Based on Pillow tutorial, but there is no textsize:
 | 
				
			||||||
        # http://pillow.readthedocs.org/en/latest/handbook/tutorial.html
 | 
					        # http://pillow.readthedocs.org/en/latest/handbook/tutorial.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Arrange
 | 
					        # Arrange
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,7 @@ class TestPsDraw(PillowTestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        im = Image.open("Tests/images/hopper.ppm")
 | 
					        im = Image.open("Tests/images/hopper.ppm")
 | 
				
			||||||
        title = "hopper"
 | 
					        title = "hopper"
 | 
				
			||||||
        box = (1*72, 2*72, 7*72, 10*72) # in points
 | 
					        box = (1*72, 2*72, 7*72, 10*72)  # in points
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Act
 | 
					        # Act
 | 
				
			||||||
        ps = PSDraw.PSDraw(fp)
 | 
					        ps = PSDraw.PSDraw(fp)
 | 
				
			||||||
| 
						 | 
					@ -26,16 +26,18 @@ class TestPsDraw(PillowTestCase):
 | 
				
			||||||
        ps.image(box, im, 75)
 | 
					        ps.image(box, im, 75)
 | 
				
			||||||
        ps.rectangle(box)
 | 
					        ps.rectangle(box)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # draw centered title
 | 
					        # draw title
 | 
				
			||||||
        ps.setfont("HelveticaNarrow-Bold", 36)
 | 
					        ps.setfont("Courier", 36)
 | 
				
			||||||
        w, h, b = ps.textsize(title)
 | 
					        ps.text((3*72, 4*72), title)
 | 
				
			||||||
        ps.text((4*72-w/2, 1*72-h), title)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ps.end_document()
 | 
					        ps.end_document()
 | 
				
			||||||
        fp.close()
 | 
					        fp.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Assert
 | 
					        # Assert
 | 
				
			||||||
        # TODO
 | 
					        # Check non-zero file was created
 | 
				
			||||||
 | 
					        import os
 | 
				
			||||||
 | 
					        self.assertTrue(os.path.isfile(tempfile))
 | 
				
			||||||
 | 
					        self.assertGreater(os.path.getsize(tempfile), 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user