mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
Added ImageGrab.grabclipboard test
This commit is contained in:
parent
467d2089be
commit
bd9cfb124b
|
@ -1,6 +1,7 @@
|
||||||
from helper import unittest, PillowTestCase
|
from helper import unittest, PillowTestCase
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PIL import ImageGrab
|
from PIL import ImageGrab
|
||||||
|
@ -11,6 +12,21 @@ try:
|
||||||
im = ImageGrab.grab()
|
im = ImageGrab.grab()
|
||||||
self.assert_image(im, im.mode, im.size)
|
self.assert_image(im, im.mode, im.size)
|
||||||
|
|
||||||
|
def test_grabclipboard(self):
|
||||||
|
if sys.platform == "darwin":
|
||||||
|
subprocess.call(['screencapture', '-c'])
|
||||||
|
else:
|
||||||
|
p = subprocess.Popen(['powershell', '-command', '-'],
|
||||||
|
stdin=subprocess.PIPE)
|
||||||
|
p.stdin.write(b'''[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
|
||||||
|
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
||||||
|
$bmp = New-Object Drawing.Bitmap 200, 200
|
||||||
|
[Windows.Forms.Clipboard]::SetImage($bmp)''')
|
||||||
|
p.communicate()
|
||||||
|
|
||||||
|
im = ImageGrab.grabclipboard()
|
||||||
|
self.assert_image(im, im.mode, im.size)
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
class TestImageGrab(PillowTestCase):
|
class TestImageGrab(PillowTestCase):
|
||||||
def test_skip(self):
|
def test_skip(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user