From 508a2b48f0deda020076ce37a2be2c4dfbaa541d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 21 Sep 2019 22:28:05 +1000 Subject: [PATCH] Test show method on CIs --- Tests/helper.py | 6 ++++++ Tests/test_imageshow.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Tests/helper.py b/Tests/helper.py index 9a41ce7df..78a2f520f 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -355,6 +355,12 @@ def on_appveyor(): return "APPVEYOR" in os.environ +def on_ci(): + # Travis and AppVeyor have "CI" + # Azure Pipelines has "TF_BUILD" + return "CI" in os.environ or "TF_BUILD" in os.environ + + if sys.platform == "win32": IMCONVERT = os.environ.get("MAGICK_HOME", "") if IMCONVERT: diff --git a/Tests/test_imageshow.py b/Tests/test_imageshow.py index 378afe2db..2f2620b74 100644 --- a/Tests/test_imageshow.py +++ b/Tests/test_imageshow.py @@ -1,6 +1,6 @@ from PIL import Image, ImageShow -from .helper import PillowTestCase, hopper +from .helper import PillowTestCase, hopper, on_ci, unittest class TestImageShow(PillowTestCase): @@ -15,7 +15,7 @@ class TestImageShow(PillowTestCase): # Restore original state ImageShow._viewers.pop() - def test_show(self): + def test_viewer_show(self): class TestViewer(ImageShow.Viewer): methodCalled = False @@ -34,6 +34,12 @@ class TestImageShow(PillowTestCase): # Restore original state ImageShow._viewers.pop(0) + @unittest.skipUnless(on_ci(), "Only run on CIs") + def test_show(self): + for mode in ("1", "I;16", "LA", "RGB", "RGBA"): + im = hopper(mode) + self.assertTrue(ImageShow.show(im)) + def test_viewer(self): viewer = ImageShow.Viewer()