Pillow/Tests/test_imageshow.py
Jon Dufresne d50445ff30 Introduce isort to automate import ordering and formatting
Similar to the recent adoption of Black. isort is a Python utility to
sort imports alphabetically and automatically separate into sections. By
using isort, contributors can quickly and automatically conform to the
projects style without thinking. Just let the tool do it.

Uses the configuration recommended by the Black to avoid conflicts of
style.

Rewrite TestImageQt.test_deprecated to no rely on import order.
2019-07-06 16:11:35 -07:00

47 lines
1.2 KiB
Python

from PIL import Image, ImageShow
from .helper import PillowTestCase, hopper
class TestImageShow(PillowTestCase):
def test_sanity(self):
dir(Image)
dir(ImageShow)
def test_register(self):
# Test registering a viewer that is not a class
ImageShow.register("not a class")
# Restore original state
ImageShow._viewers.pop()
def test_show(self):
class TestViewer(ImageShow.Viewer):
methodCalled = False
def show_image(self, image, **options):
self.methodCalled = True
return True
viewer = TestViewer()
ImageShow.register(viewer, -1)
for mode in ("1", "I;16", "LA", "RGB", "RGBA"):
im = hopper(mode)
self.assertTrue(ImageShow.show(im))
self.assertTrue(viewer.methodCalled)
# Restore original state
ImageShow._viewers.pop(0)
def test_viewer(self):
viewer = ImageShow.Viewer()
self.assertIsNone(viewer.get_format(None))
self.assertRaises(NotImplementedError, viewer.get_command, None)
def test_viewers(self):
for viewer in ImageShow._viewers:
viewer.get_command("test.jpg")