Merge pull request #1633 from wiredfool/windows-2.6-tests

Fixing test failures on python 2.6/windows
This commit is contained in:
Hugo 2016-01-03 23:42:19 +02:00
commit 12a9bf614b
2 changed files with 14 additions and 3 deletions

View File

@ -1,5 +1,5 @@
from helper import unittest, PillowTestCase, hopper, py3
import sys
class TestImageGetIm(PillowTestCase):
@ -10,7 +10,14 @@ class TestImageGetIm(PillowTestCase):
if py3:
self.assertIn("PyCapsule", type_repr)
self.assertIsInstance(im.im.id, int)
if sys.hexversion < 0x2070000:
# py2.6 x64, windows
target_types = (int, long)
else:
target_types = (int)
self.assertIsInstance(im.im.id, target_types)
if __name__ == '__main__':

View File

@ -72,7 +72,11 @@ if sys.platform.startswith('win32'):
memcpy(bp, ctypes.byref(bf), ctypes.sizeof(bf))
memcpy(bp + ctypes.sizeof(bf), ctypes.byref(bi), bi.biSize)
memcpy(bp + bf.bfOffBits, pixels, bi.biSizeImage)
return bytearray(buf)
try:
return bytearray(buf)
except ValueError:
# py2.6
return buffer(buf)[:]
class TestImageWinPointers(PillowTestCase):
def test_pointer(self):