Added base method and constants to test_imagedraw

The method `create_base_image_draw` will be used in all the new draw
tests.
This commit is contained in:
Terseus 2014-04-04 10:27:08 +02:00
parent dbe3db6fc5
commit 7de14a51dd

View File

@ -2,6 +2,13 @@ from tester import *
from PIL import Image
from PIL import ImageDraw
import os.path
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GRAY = (190, 190, 190)
DEFAULT_MODE = 'RGB'
IMAGES_PATH = os.path.join('Tests', 'images', 'imagedraw')
def test_sanity():
@ -26,3 +33,12 @@ def test_deprecated():
assert_warning(DeprecationWarning, lambda: draw.setink(0))
assert_warning(DeprecationWarning, lambda: draw.setfill(0))
def create_base_image_draw(size, mode=DEFAULT_MODE, background1=WHITE, background2=GRAY):
img = Image.new(mode, size, background1)
for x in range(0, size[0]):
for y in range(0, size[1]):
if (x + y) % 2 == 0:
img.putpixel((x, y), background2)
return (img, ImageDraw.Draw(img))