From a1b9f94d60983a5d082b7256f52c1b85524bbe31 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 21 Oct 2018 16:42:41 +0300 Subject: [PATCH 1/5] skipUnless takes a condition and _reason_ --- Tests/test_features.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/test_features.py b/Tests/test_features.py index 54d668d2f..c1f5b5cc6 100644 --- a/Tests/test_features.py +++ b/Tests/test_features.py @@ -23,19 +23,19 @@ class TestFeatures(PillowTestCase): self.assertEqual(features.check_feature(feature), features.check(feature)) - @unittest.skipUnless(HAVE_WEBP, True) + @unittest.skipUnless(HAVE_WEBP, "WebP not available") def check_webp_transparency(self): self.assertEqual(features.check('transp_webp'), not _webp.WebPDecoderBuggyAlpha()) self.assertEqual(features.check('transp_webp'), _webp.HAVE_TRANSPARENCY) - @unittest.skipUnless(HAVE_WEBP, True) + @unittest.skipUnless(HAVE_WEBP, "WebP not available") def check_webp_mux(self): self.assertEqual(features.check('webp_mux'), _webp.HAVE_WEBPMUX) - @unittest.skipUnless(HAVE_WEBP, True) + @unittest.skipUnless(HAVE_WEBP, "WebP not available") def check_webp_anim(self): self.assertEqual(features.check('webp_anim'), _webp.HAVE_WEBPANIM) From cfc4c3e1011ff9f44c91154d1ffea0d78feae212 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 21 Oct 2018 16:44:12 +0300 Subject: [PATCH 2/5] Switch check_ to test_ to enable them --- Tests/test_features.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/test_features.py b/Tests/test_features.py index c1f5b5cc6..312894cb4 100644 --- a/Tests/test_features.py +++ b/Tests/test_features.py @@ -24,19 +24,19 @@ class TestFeatures(PillowTestCase): features.check(feature)) @unittest.skipUnless(HAVE_WEBP, "WebP not available") - def check_webp_transparency(self): + def test_webp_transparency(self): self.assertEqual(features.check('transp_webp'), not _webp.WebPDecoderBuggyAlpha()) self.assertEqual(features.check('transp_webp'), _webp.HAVE_TRANSPARENCY) @unittest.skipUnless(HAVE_WEBP, "WebP not available") - def check_webp_mux(self): + def test_webp_mux(self): self.assertEqual(features.check('webp_mux'), _webp.HAVE_WEBPMUX) @unittest.skipUnless(HAVE_WEBP, "WebP not available") - def check_webp_anim(self): + def test_webp_anim(self): self.assertEqual(features.check('webp_anim'), _webp.HAVE_WEBPANIM) From cbba2c24bfa330e79cc12c133ab35a034ac3f9dd Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 21 Oct 2018 17:05:14 +0300 Subject: [PATCH 3/5] Remove unused helper method --- Tests/test_format_hsv.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Tests/test_format_hsv.py b/Tests/test_format_hsv.py index d7820400e..8728c484b 100644 --- a/Tests/test_format_hsv.py +++ b/Tests/test_format_hsv.py @@ -13,12 +13,8 @@ class TestFormatHSV(PillowTestCase): return float(i)/255.0 def str_to_float(self, i): - return float(ord(i))/255.0 - def to_int(self, f): - return int(f*255.0) - def tuple_to_ints(self, tp): x, y, z = tp return (int(x*255.0), int(y*255.0), int(z*255.0)) From e33812c56cf5d00015e598d14f02f972db0e6ed4 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 21 Oct 2018 17:05:40 +0300 Subject: [PATCH 4/5] Remove redundant parentheses --- Tests/test_format_hsv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/test_format_hsv.py b/Tests/test_format_hsv.py index 8728c484b..0385bd66f 100644 --- a/Tests/test_format_hsv.py +++ b/Tests/test_format_hsv.py @@ -17,7 +17,7 @@ class TestFormatHSV(PillowTestCase): def tuple_to_ints(self, tp): x, y, z = tp - return (int(x*255.0), int(y*255.0), int(z*255.0)) + return int(x*255.0), int(y*255.0), int(z*255.0) def test_sanity(self): Image.new('HSV', (100, 100)) From 06ad343d3586268572ee3f86c176a1870f677c42 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 21 Oct 2018 17:47:35 +0300 Subject: [PATCH 5/5] Simplify skipping --- Tests/test_pyroma.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Tests/test_pyroma.py b/Tests/test_pyroma.py index cf5fc361f..e147161a7 100644 --- a/Tests/test_pyroma.py +++ b/Tests/test_pyroma.py @@ -5,19 +5,12 @@ from PIL import __version__ try: import pyroma except ImportError: - # Skip via setUp() - pass + pyroma = None class TestPyroma(PillowTestCase): - def setUp(self): - try: - import pyroma - assert pyroma # Ignore warning - except ImportError: - self.skipTest("ImportError") - + @unittest.skipUnless(pyroma, "Pyroma is not installed") def test_pyroma(self): # Arrange data = pyroma.projectdata.get_data(".")