Refactor cffi import and skipping

This commit is contained in:
Hugo 2018-07-04 18:01:24 +03:00
parent d7e4d3db3f
commit 4218a769d7

View File

@ -2,8 +2,9 @@ from helper import unittest, PillowTestCase, hopper, on_appveyor
try:
from PIL import PyAccess
import cffi
except ImportError:
# Skip in setUp()
cffi = None
pass
from PIL import Image
@ -113,38 +114,20 @@ class TestImageGetPixel(AccessTest):
self.check(mode, 2**16-1)
@unittest.skipIf(cffi is None, "No cffi")
class TestCffiPutPixel(TestImagePutPixel):
_need_cffi_access = True
def setUp(self):
try:
import cffi
assert cffi # silence warning
except ImportError:
self.skipTest("No cffi")
@unittest.skipIf(cffi is None, "No cffi")
class TestCffiGetPixel(TestImageGetPixel):
_need_cffi_access = True
def setUp(self):
try:
import cffi
assert cffi # silence warning
except ImportError:
self.skipTest("No cffi")
@unittest.skipIf(cffi is None, "No cffi")
class TestCffi(AccessTest):
_need_cffi_access = True
def setUp(self):
try:
import cffi
assert cffi # silence warning
except ImportError:
self.skipTest("No cffi")
def _test_get_access(self, im):
"""Do we get the same thing as the old pixel access