Simplify test skipping

This commit is contained in:
Hugo 2018-08-04 20:46:03 +03:00
parent da9a3dae63
commit 901c1e2aea
3 changed files with 4 additions and 10 deletions

View File

@ -5,18 +5,13 @@ from PIL import Image
try: try:
from PIL import _webp from PIL import _webp
except ImportError: except ImportError:
pass _webp = None
# Skip in setUp()
@unittest.skipIf(_webp is None, "WebP support not installed")
class TestFileWebpAlpha(PillowTestCase): class TestFileWebpAlpha(PillowTestCase):
def setUp(self): def setUp(self):
try:
from PIL import _webp
except ImportError:
self.skipTest('WebP support not installed')
if _webp.WebPDecoderBuggyAlpha(self): if _webp.WebPDecoderBuggyAlpha(self):
self.skipTest("Buggy early version of WebP installed, " self.skipTest("Buggy early version of WebP installed, "
"not testing transparency") "not testing transparency")

View File

@ -18,11 +18,10 @@ except (OSError, ImportError) as v:
TK_MODES = ('1', 'L', 'P', 'RGB', 'RGBA') TK_MODES = ('1', 'L', 'P', 'RGB', 'RGBA')
@unittest.skipIf(not HAS_TK, "Tk not installed")
class TestImageTk(PillowTestCase): class TestImageTk(PillowTestCase):
def setUp(self): def setUp(self):
if not HAS_TK:
self.skipTest("Tk not installed")
try: try:
# setup tk # setup tk
tk.Frame() tk.Frame()

View File

@ -8,9 +8,9 @@ except ImportError:
pyroma = None pyroma = None
@unittest.skipIf(pyroma is None, "Pyroma is not installed")
class TestPyroma(PillowTestCase): class TestPyroma(PillowTestCase):
@unittest.skipUnless(pyroma, "Pyroma is not installed")
def test_pyroma(self): def test_pyroma(self):
# Arrange # Arrange
data = pyroma.projectdata.get_data(".") data = pyroma.projectdata.get_data(".")