mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-23 13:44:47 +03:00
Raise error if grabclipboard is used not on macOS or Windows
This commit is contained in:
parent
1ebaf0bd6c
commit
13ab784c51
|
@ -26,7 +26,7 @@ class TestImageGrab:
|
||||||
def test_grabclipboard(self):
|
def test_grabclipboard(self):
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
subprocess.call(["screencapture", "-cx"])
|
subprocess.call(["screencapture", "-cx"])
|
||||||
else:
|
elif sys.platform == "win32":
|
||||||
p = subprocess.Popen(["powershell", "-command", "-"], stdin=subprocess.PIPE)
|
p = subprocess.Popen(["powershell", "-command", "-"], stdin=subprocess.PIPE)
|
||||||
p.stdin.write(
|
p.stdin.write(
|
||||||
b"""[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
|
b"""[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
|
||||||
|
@ -35,6 +35,9 @@ $bmp = New-Object Drawing.Bitmap 200, 200
|
||||||
[Windows.Forms.Clipboard]::SetImage($bmp)"""
|
[Windows.Forms.Clipboard]::SetImage($bmp)"""
|
||||||
)
|
)
|
||||||
p.communicate()
|
p.communicate()
|
||||||
|
else:
|
||||||
|
self.assertRaises(NotImplementedError, ImageGrab.grabclipboard)
|
||||||
|
return
|
||||||
|
|
||||||
im = ImageGrab.grabclipboard()
|
im = ImageGrab.grabclipboard()
|
||||||
assert_image(im, im.mode, im.size)
|
assert_image(im, im.mode, im.size)
|
||||||
|
|
|
@ -110,3 +110,6 @@ def grabclipboard():
|
||||||
|
|
||||||
return BmpImagePlugin.DibImageFile(io.BytesIO(data))
|
return BmpImagePlugin.DibImageFile(io.BytesIO(data))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise NotImplementedError("grabclipboard is macOS and Windows only")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user