mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 01:13:34 +03:00
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:
parent
dbe3db6fc5
commit
7de14a51dd
|
@ -2,6 +2,13 @@ from tester import *
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL import ImageDraw
|
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():
|
def test_sanity():
|
||||||
|
|
||||||
|
@ -26,3 +33,12 @@ def test_deprecated():
|
||||||
assert_warning(DeprecationWarning, lambda: draw.setink(0))
|
assert_warning(DeprecationWarning, lambda: draw.setink(0))
|
||||||
assert_warning(DeprecationWarning, lambda: draw.setfill(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))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user