Pillow/Tests/test_imagegrab.py

49 lines
1.1 KiB
Python
Raw Normal View History

2014-07-07 21:03:50 +04:00
from helper import unittest, PillowTestCase
import sys
try:
from PIL import ImageGrab
class TestImageGrab(PillowTestCase):
2014-06-10 13:10:47 +04:00
def test_grab(self):
im = ImageGrab.grab()
self.assert_image(im, im.mode, im.size)
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