mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
deprecate Image.show(command="...")
This commit is contained in:
parent
f4fb9c5403
commit
66954ad176
|
@ -664,6 +664,18 @@ class TestImage:
|
|||
except OSError as e:
|
||||
assert str(e) == "buffer overrun when reading image file"
|
||||
|
||||
def test_show_deprecation(self, monkeypatch):
|
||||
monkeypatch.setattr(Image, "_show", lambda *args, **kwargs: None)
|
||||
|
||||
im = Image.new("RGB", (50, 50), "white")
|
||||
|
||||
with pytest.warns(None) as raised:
|
||||
im.show()
|
||||
assert not raised
|
||||
|
||||
with pytest.warns(DeprecationWarning):
|
||||
im.show(command="mock")
|
||||
|
||||
|
||||
class MockEncoder:
|
||||
pass
|
||||
|
|
|
@ -12,6 +12,14 @@ Deprecated features
|
|||
Below are features which are considered deprecated. Where appropriate,
|
||||
a ``DeprecationWarning`` is issued.
|
||||
|
||||
Image.show
|
||||
~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.2.0
|
||||
|
||||
The ``command`` parameter was deprecated and will be removed in a future release.
|
||||
Use a subclass of ``ImageShow.Viewer`` instead.
|
||||
|
||||
ImageFile.raise_ioerror
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -2172,9 +2172,15 @@ class Image:
|
|||
|
||||
:param title: Optional title to use for the image window,
|
||||
where possible.
|
||||
:param command: command used to show the image
|
||||
"""
|
||||
|
||||
if command is not None:
|
||||
warnings.warn(
|
||||
"The command parameter was deprecated and will be removed in a future"
|
||||
"release. Use a subclass of ImageShow.Viewer instead.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
|
||||
_show(self, title=title, command=command)
|
||||
|
||||
def split(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user