diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py index 0e29ea693..e3905cb3d 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -26,7 +26,7 @@ class TestImageGrab: def test_grabclipboard(self): if sys.platform == "darwin": subprocess.call(["screencapture", "-cx"]) - else: + elif sys.platform == "win32": p = subprocess.Popen(["powershell", "-command", "-"], stdin=subprocess.PIPE) p.stdin.write( b"""[Reflection.Assembly]::LoadWithPartialName("System.Drawing") @@ -35,6 +35,9 @@ $bmp = New-Object Drawing.Bitmap 200, 200 [Windows.Forms.Clipboard]::SetImage($bmp)""" ) p.communicate() + else: + self.assertRaises(NotImplementedError, ImageGrab.grabclipboard) + return im = ImageGrab.grabclipboard() assert_image(im, im.mode, im.size) diff --git a/src/PIL/ImageGrab.py b/src/PIL/ImageGrab.py index cbb284d9e..0355ed482 100644 --- a/src/PIL/ImageGrab.py +++ b/src/PIL/ImageGrab.py @@ -110,3 +110,6 @@ def grabclipboard(): return BmpImagePlugin.DibImageFile(io.BytesIO(data)) return data + + else: + raise NotImplementedError("grabclipboard is macOS and Windows only")