mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-14 11:26:27 +03:00
Merge pull request #4706 from radarhere/imageshow
Do not ignore viewer if ImageShow.register order is zero
This commit is contained in:
commit
095177fb28
|
@ -17,19 +17,21 @@ def test_register():
|
|||
ImageShow._viewers.pop()
|
||||
|
||||
|
||||
def test_viewer_show():
|
||||
@pytest.mark.parametrize(
|
||||
"order", [-1, 0],
|
||||
)
|
||||
def test_viewer_show(order):
|
||||
class TestViewer(ImageShow.Viewer):
|
||||
methodCalled = False
|
||||
|
||||
def show_image(self, image, **options):
|
||||
self.methodCalled = True
|
||||
return True
|
||||
|
||||
viewer = TestViewer()
|
||||
ImageShow.register(viewer, -1)
|
||||
ImageShow.register(viewer, order)
|
||||
|
||||
for mode in ("1", "I;16", "LA", "RGB", "RGBA"):
|
||||
with hopper() as im:
|
||||
viewer.methodCalled = False
|
||||
with hopper(mode) as im:
|
||||
assert ImageShow.show(im)
|
||||
assert viewer.methodCalled
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ def register(viewer, order=1):
|
|||
pass # raised if viewer wasn't a class
|
||||
if order > 0:
|
||||
_viewers.append(viewer)
|
||||
elif order < 0:
|
||||
else:
|
||||
_viewers.insert(0, viewer)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user