代码拉取完成,页面将自动刷新
同步操作将从 openKylin/pillow 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import os
import sys
from io import StringIO
from PIL import Image, PSDraw
from .helper import PillowTestCase
class TestPsDraw(PillowTestCase):
def _create_document(self, ps):
title = "hopper"
box = (1 * 72, 2 * 72, 7 * 72, 10 * 72) # in points
ps.begin_document(title)
# draw diagonal lines in a cross
ps.line((1 * 72, 2 * 72), (7 * 72, 10 * 72))
ps.line((7 * 72, 2 * 72), (1 * 72, 10 * 72))
# draw the image (75 dpi)
with Image.open("Tests/images/hopper.ppm") as im:
ps.image(box, im, 75)
ps.rectangle(box)
# draw title
ps.setfont("Courier", 36)
ps.text((3 * 72, 4 * 72), title)
ps.end_document()
def test_draw_postscript(self):
# Based on Pillow tutorial, but there is no textsize:
# https://pillow.readthedocs.io/en/latest/handbook/tutorial.html#drawing-postscript
# Arrange
tempfile = self.tempfile("temp.ps")
with open(tempfile, "wb") as fp:
# Act
ps = PSDraw.PSDraw(fp)
self._create_document(ps)
# Assert
# Check non-zero file was created
self.assertTrue(os.path.isfile(tempfile))
self.assertGreater(os.path.getsize(tempfile), 0)
def test_stdout(self):
# Temporarily redirect stdout
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
ps = PSDraw.PSDraw()
self._create_document(ps)
# Reset stdout
sys.stdout = old_stdout
self.assertNotEqual(mystdout.getvalue(), "")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。