mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
more extensive testing, matches original c code
This commit is contained in:
parent
663f881b21
commit
273a5014d2
|
@ -21,4 +21,44 @@ def test_get():
|
|||
get.test_pixel()
|
||||
get.test_image()
|
||||
|
||||
def _test_get_access(im):
|
||||
""" Do we get the same thing as the old pixel access """
|
||||
|
||||
""" Using private interfaces, forcing a capi access and a pyaccess for the same image """
|
||||
caccess = im.im.pixel_access(False)
|
||||
access = PyAccess.new(im, False)
|
||||
|
||||
w,h = im.size
|
||||
for x in range(0,w,10):
|
||||
for y in range(0,h,10):
|
||||
assert_equal(caccess[(x,y)], access[(x,y)])
|
||||
|
||||
def test_get_vs_c():
|
||||
_test_get_access(lena('RGB'))
|
||||
_test_get_access(lena('RGBA'))
|
||||
_test_get_access(lena('L'))
|
||||
_test_get_access(lena('1'))
|
||||
_test_get_access(lena('P'))
|
||||
|
||||
|
||||
def _test_set_access(im, color):
|
||||
""" Are we writing the correct bits into the image? """
|
||||
|
||||
""" Using private interfaces, forcing a capi access and a pyaccess for the same image """
|
||||
caccess = im.im.pixel_access(False)
|
||||
access = PyAccess.new(im, False)
|
||||
|
||||
w,h = im.size
|
||||
for x in range(0,w,10):
|
||||
for y in range(0,h,10):
|
||||
access[(x,y)] = color
|
||||
assert_equal(caccess[(x,y)], color)
|
||||
|
||||
def test_set_vs_c():
|
||||
_test_set_access(lena('RGB'), (255, 128,0) )
|
||||
_test_set_access(lena('RGBA'), (255, 192, 128, 0))
|
||||
_test_set_access(lena('L'), 128)
|
||||
_test_set_access(lena('1'), 255)
|
||||
_test_set_access(lena('P') , 128)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user