Test PSDraw

This commit is contained in:
hugovk 2014-12-11 13:06:53 +02:00
parent 9581da4daa
commit 385ad47a9b

42
Tests/test_psdraw.py Normal file
View File

@ -0,0 +1,42 @@
from helper import unittest, PillowTestCase, hopper
class TestPsDraw(PillowTestCase):
def test_draw_postscript(self):
# Taken from Pillow tutorial:
# http://pillow.readthedocs.org/en/latest/handbook/tutorial.html
# Arrange
from PIL import Image
from PIL import PSDraw
tempfile = self.tempfile('temp.ps')
im = Image.open("Tests/images/hopper.ppm")
title = "hopper"
box = (1*72, 2*72, 7*72, 10*72) # in points
# Act
ps = PSDraw.PSDraw(tempfile)
ps.begin_document(title)
# draw the image (75 dpi)
ps.image(box, im, 75)
ps.rectangle(box)
# draw centered title
ps.setfont("HelveticaNarrow-Bold", 36)
w, h, b = ps.textsize(title)
ps.text((4*72-w/2, 1*72-h), title)
ps.end_document()
# Assert
# TODO
if __name__ == '__main__':
unittest.main()
# End of file