Merge pull request #4706 from radarhere/imageshow

Do not ignore viewer if ImageShow.register order is zero
This commit is contained in:
Hugo van Kemenade 2020-06-18 15:40:24 +03:00 committed by GitHub
commit 095177fb28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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)