2015-06-17 00:08:10 +03:00
|
|
|
from helper import unittest, PillowTestCase, on_appveyor
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-09-16 17:05:22 +04:00
|
|
|
import sys
|
|
|
|
|
2012-10-16 00:26:38 +04:00
|
|
|
try:
|
|
|
|
from PIL import ImageGrab
|
|
|
|
|
2014-07-19 21:21:18 +04:00
|
|
|
class TestImageGrab(PillowTestCase):
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2015-06-16 23:35:34 +03:00
|
|
|
@unittest.skipIf(on_appveyor(), "Test fails on appveyor")
|
2014-06-10 13:10:47 +04:00
|
|
|
def test_grab(self):
|
|
|
|
im = ImageGrab.grab()
|
|
|
|
self.assert_image(im, im.mode, im.size)
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2015-06-16 23:35:34 +03:00
|
|
|
@unittest.skipIf(on_appveyor(), "Test fails on appveyor")
|
2014-06-10 13:10:47 +04:00
|
|
|
def test_grab2(self):
|
|
|
|
im = ImageGrab.grab()
|
|
|
|
self.assert_image(im, im.mode, im.size)
|
|
|
|
|
|
|
|
except ImportError:
|
2014-07-19 21:21:18 +04:00
|
|
|
class TestImageGrab(PillowTestCase):
|
2014-06-10 13:10:47 +04:00
|
|
|
def test_skip(self):
|
|
|
|
self.skipTest("ImportError")
|
|
|
|
|
|
|
|
|
2014-09-16 17:05:22 +04:00
|
|
|
class TestImageGrabImport(PillowTestCase):
|
|
|
|
|
|
|
|
def test_import(self):
|
|
|
|
# Arrange
|
|
|
|
exception = None
|
|
|
|
|
|
|
|
# Act
|
|
|
|
try:
|
|
|
|
from PIL import ImageGrab
|
|
|
|
ImageGrab.__name__ # dummy to prevent Pyflakes warning
|
2014-09-16 18:19:15 +04:00
|
|
|
except Exception as e:
|
|
|
|
exception = e
|
2014-09-16 17:05:22 +04:00
|
|
|
|
|
|
|
# Assert
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
self.assertIsNone(exception, None)
|
|
|
|
else:
|
2014-09-16 17:44:51 +04:00
|
|
|
self.assertIsInstance(exception, ImportError)
|
2014-09-16 18:41:03 +04:00
|
|
|
self.assertEqual(str(exception), "ImageGrab is Windows only")
|
2014-09-16 17:05:22 +04:00
|
|
|
|
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|
|
|
|
|
|
|
|
# End of file
|