mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-23 07:10:33 +03:00
Merge pull request #3424 from radarhere/imagegrab
Improved ImageGrab tests
This commit is contained in:
commit
cd3dc0794d
|
@ -1,17 +1,32 @@
|
|||
from helper import unittest, PillowTestCase, on_appveyor
|
||||
from helper import unittest, PillowTestCase
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
from PIL import ImageGrab
|
||||
|
||||
class TestImageGrab(PillowTestCase):
|
||||
|
||||
@unittest.skipIf(on_appveyor(), "Test fails on appveyor")
|
||||
def test_grab(self):
|
||||
im = ImageGrab.grab()
|
||||
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:
|
||||
class TestImageGrab(PillowTestCase):
|
||||
def test_skip(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user