Pillow/Tests/test_imagegrab.py

51 lines
1.2 KiB
Python
Raw Normal View History

2015-06-17 00:08:10 +03:00
from helper import unittest, PillowTestCase, on_appveyor
import sys
try:
from PIL import ImageGrab
class TestImageGrab(PillowTestCase):
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)
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:
class TestImageGrab(PillowTestCase):
2014-06-10 13:10:47 +04:00
def test_skip(self):
self.skipTest("ImportError")
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
# 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-06-10 13:10:47 +04:00
if __name__ == '__main__':
unittest.main()
# End of file