mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-23 05:34:45 +03:00
Use command argument
This commit is contained in:
parent
dd4b61c83c
commit
b6c6ed6b66
|
@ -12,6 +12,7 @@ from .helper import (
|
||||||
assert_image_similar,
|
assert_image_similar,
|
||||||
assert_not_all_same,
|
assert_not_all_same,
|
||||||
hopper,
|
hopper,
|
||||||
|
is_mingw,
|
||||||
is_win32,
|
is_win32,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -609,6 +610,24 @@ class TestImage:
|
||||||
|
|
||||||
assert not fp.closed
|
assert not fp.closed
|
||||||
|
|
||||||
|
def test_show_command(self, tmp_path):
|
||||||
|
# Arrange
|
||||||
|
temp_file = str(tmp_path / "opened")
|
||||||
|
with open(temp_file, "a") as f:
|
||||||
|
f.close()
|
||||||
|
assert os.path.exists(temp_file)
|
||||||
|
im = hopper()
|
||||||
|
|
||||||
|
# Act
|
||||||
|
im.show(
|
||||||
|
command=("del" if (is_win32() and not is_mingw()) else "rm")
|
||||||
|
+ " "
|
||||||
|
+ temp_file
|
||||||
|
)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert not os.path.exists(temp_file)
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"test_module", [PIL, Image],
|
"test_module", [PIL, Image],
|
||||||
)
|
)
|
||||||
|
|
|
@ -44,6 +44,16 @@ def show(image, title=None, **options):
|
||||||
:param \**options: Additional viewer options.
|
:param \**options: Additional viewer options.
|
||||||
:returns: True if a suitable viewer was found, false otherwise.
|
:returns: True if a suitable viewer was found, false otherwise.
|
||||||
"""
|
"""
|
||||||
|
command = options.get("command")
|
||||||
|
if command:
|
||||||
|
|
||||||
|
class CommandViewer(Viewer):
|
||||||
|
def get_command(self, file):
|
||||||
|
return command + " " + file
|
||||||
|
|
||||||
|
CommandViewer().show(image)
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
for viewer in _viewers:
|
for viewer in _viewers:
|
||||||
if viewer.show(image, title=title, **options):
|
if viewer.show(image, title=title, **options):
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user